how to use unicode?(2)
gfu at public.nn.gx.cn
Mon Jan 27 16:18:07 CET 2003
>> >>> u'行都'
>In Python 2.2, you cannot put non-ASCII characters into a Unicode
>literals(*). In Python 2.3, this is possible, but only if you declare
>the file encoding (i.e. you cannot enter them readily in interactive mode).
>So if you want those characters in a string, you need to write
>Here, U+884C and U+90FD are the Unicode code points of the two
>characters you show above. Alternatively, writing
>should also work, provided you have a codec for gb2312 installed (and
>provided your input is really encoded in gb2312).
>(*) Strictly speaking, you can put any Latin-1 into a Unicode literal if
>the file is encoded in Latin-1.
= = = = = = = = = = = = = = = = = = = =
>>> print s
>>> s = unicode('行都', 'gb2312')
UnicodeError: ASCII encoding error: ordinal not in range(128)
how to install a codec for gb2312 ? how to my input is really encoded in gb2312?
More information about the Python-list