首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > perl python >

python查找乱码有关问题

2013-08-13 
python查找乱码问题。Python 2.7.2 (default, Jun 16 2012, 12:38:40) [GCC 4.2.1 Compatible Apple Clang

python查找乱码问题。

Python 2.7.2 (default, Jun 16 2012, 12:38:40)
[GCC 4.2.1 Compatible Apple Clang 4.0 (tags/Apple/clang-418.0.60)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> s = "%E5%A4%A9%E6%89%8D"
>>> import urllib
>>> urllib.unquote(s)
'\xe5\xa4\xa9\xe6\x89\x8d'
>>> print _
天才
>>> s.decode("gbk")
u'%E5%A4%A9%E6%89%8D'
>>> print _
%E5%A4%A9%E6%89%8D
>>> t = urllib.unquote(s)
>>> t
'\xe5\xa4\xa9\xe6\x89\x8d'
>>> t.decode("gbk")
u'\u6fb6\u2542\u58a0'
>>> print _
澶╂墠
>>> t
'\xe5\xa4\xa9\xe6\x89\x8d'
>>> t.decode("utf8").encode("gbk")
'\xcc\xec\xb2\xc5'
>>> urllib.quote(_)
'%CC%EC%B2%C5'
>>>
KeyboardInterrupt
>>>

热点排行