how to get my character?

contro opinion contropinion at gmail.com
Thu Jan 26 07:52:48 EST 2012


my system:xp+python27 the codec, xp gbk;python 27 ascii

 a = '你好'
a
'\xc4\xe3\xba\xc3'
print a
你好
'\xc4\xe3\xba\xc3'.decode('gbk')
u'\u4f60\u597d'
'\xc4\xe3\xba\xc3'.encode('gbk')
Traceback (most recent call last): File "", line 1, in UnicodeDecodeError:
'ascii' codec can't decode byte 0xc4 in position 0: ordinal not in
range(128)

 how can i get "你好" from '\xc4\xe3\xba\xc3' ?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20120126/9e03ae6e/attachment.html>


More information about the Python-list mailing list