Re: how to get my character?

2012-01-26 Thread contro opinion
re any results you get from http://stackoverflow.com/** > questions/9018303/how-to-get-**my-character<http://stackoverflow.com/questions/9018303/how-to-get-my-character>with > python-list. > > Lutz > -- > http://mail.python.org/**mailman/listinfo/python-list<http://mail.python.org/mailman/listinfo/python-list> > -- http://mail.python.org/mailman/listinfo/python-list

Re: how to get my character?

2012-01-26 Thread Dave Angel
On 01/26/2012 07:52 AM, contro opinion wrote: > 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,

Re: how to get my character?

2012-01-26 Thread Lutz Horn
Hi, On Thu, 26 Jan 2012 20:52:48 +0800, contro opinion wrote: how can i get "你好" from 'xc4xe3xbaxc3' ? Please share any results you get from http://stackoverflow.com/questions/9018303/how-to-get-my-character with python-list. Lutz -- http://mail.python.org/mailman/listinfo/python-list

Re: how to get my character?

2012-01-26 Thread Peter Otten
contro opinion wrote: > how can i get "你好" from '\xc4\xe3\xba\xc3' ? >>> print '\xc4\xe3\xba\xc3'.decode("gbk") 你好 General rule: use the decode() method to convert from bytestring to unicode and encode() to convert from unicode to bytestring. bytestring.encode(x) will implicitly try bytestrin

how to get my character?

2012-01-26 Thread contro opinion
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 pos