如何改变'\ x ??' 在python中unicode?

era*_*ran 0 python encoding

我有一个字符串:

\xe2\x80\x8e\xd7\x93\xd7\x9c\xd7\x99\xd7\xaa\xe2\x80\x8e
Run Code Online (Sandbox Code Playgroud)

想要使用python将其改为unicode

我怎么做?

Mar*_*ers 6

已经是 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: