1. 输出所有汉字
for ch in xrange(0x4e00, 0x9fa6):
print unichr(ch)
2. 在终端以汉字形式输出unicode字符
a= u'\u6211\u7684\u89c6\u9891'
print unicode(a)
3. 打印出url中utf-8编码字符
import urllib2
a= '%E6%88%91%E7%9A%84%E8%A7%86%E9%A2%91'
a=urllib2.unquote(a)
a=a.decode('utf8')
print unicode(a)
一条命令 print(unicode(urllib2.unquote(a).decode('utf8')))
for ch in xrange(0x4e00, 0x9fa6):
print unichr(ch)
2. 在终端以汉字形式输出unicode字符
a= u'\u6211\u7684\u89c6\u9891'
print unicode(a)
3. 打印出url中utf-8编码字符
import urllib2
a= '%E6%88%91%E7%9A%84%E8%A7%86%E9%A2%91'
a=urllib2.unquote(a)
a=a.decode('utf8')
print unicode(a)
一条命令 print(unicode(urllib2.unquote(a).decode('utf8')))