# 只显示字母与数字
str1 = "521.ithomer.NET $ @ # ! 1314"
fmt = "abcdefghijklmnopqrstuvwxyz0123456789"
for c in str1:
if not c in fmt:
str1 = str1.replace(c,'')
print str1 # 521ithomer1314
Python unicode字节串转成中文问题
Example 1:
>>> s = r"\u65b0\u6d6a\u5fae\u535a\u6ce8\u518c"
>>> s
'\\u65b0\\u6d6a\\u5fae\\u535a\\u6ce8\\u518c'
>>> print s
\u65b0\u6d6a\u5fae\u535a\u6ce8\u518c
>>> s = s.decode("unicode_escape"); #就是这个函数
>>> print s
新浪微博注册
Example 2:
>>> str_ = "Russopho\xe9bic, clichd and just pl\xe9ain stupid."
>>> print str_
Russopho?bic, clichd and just pl?ain stupid.
>>> str_ = str_.decode("unicode_escape")
>>> print str_
Russophoébic, clichd and just pléain stupid.