我有一个字符串:
\xe2\x80\x8e\xd7\x93\xd7\x9c\xd7\x99\xd7\xaa\xe2\x80\x8e
Run Code Online (Sandbox Code Playgroud)
想要使用python将其改为unicode
我怎么做?
那已经是 UTF-8数据; python向您显示字符串文字形式.
>>> print '\xe2\x80\x8e\xd7\x93\xd7\x9c\xd7\x99\xd7\xaa\xe2\x80\x8e'.decode('utf8')
??????
Run Code Online (Sandbox Code Playgroud)
上面的行将UTF-8数据解码为unicode具有.decode('utf8') and prints that; theprint statement inspects the encoding used by my terminal and re-encodes theunicode`对象的对象,以便我的终端可以正确显示它.
您可能想要阅读Python和Unicode:
Ned Batchelder的实用Unicode
绝对最低每个软件开发人员绝对必须知道关于Unicode和字符集(没有任何借口!)作者:Joel Spolsky