unicode wrap unicode object?

ygao ygao2004 at gmail.com
Sat Apr 8 04:17:53 EDT 2006


sorry,my poor english.
I got a solution  from others.
I must use utf-8 for chinese.


>>> import sys
>>> reload(sys)
>>> sys.setdefaultencoding("utf-8")
>>> s='\xe9\xab\x98' #this uff-8 string
>>> ss=U'\xe9\xab\x98'
>>> ss1=ss.encode('unicode_escape').decode('string_escape')
>>> s1=s.decode('unicode_escape')
>>> s1==ss
True
>>> ss1==s
True
>>>




More information about the Python-list mailing list