how to get my character?
d at davea.name
Thu Jan 26 08:17:49 EST 2012
On 01/26/2012 07:52 AM, contro opinion wrote:
> my system:xp+python27 the codec, xp gbk;python 27 ascii
> a = '你好'
> print a
> Traceback (most recent call last): File "", line 1, in UnicodeDecodeError:
> 'ascii' codec can't decode byte 0xc4 in position 0: ordinal not in
> how can i get "你好" from '\xc4\xe3\xba\xc3' ?
I don't have 'gbk' as my encoding. But on your system, if you simply
print it, you should get the proper characters.
a = '\xc4\xe3\xba\xc3'
And see if it now make sense. You're looking at the encoded form of the
two characters. You could decode it to the two-character unicode string,
as you showed above. But it makes no sense to try to encode something
that's already encoded.
More information about the Python-list