如何更改'\x??'到python中的unicode?

2024-04-20 13:51:47 发布

您现在位置:Python中文网/ 问答频道 /正文

我有一根绳子:

\xe2\x80\x8e\xd7\x93\xd7\x9c\xd7\x99\xd7\xaa\xe2\x80\x8e

想用python把它改成unicode吗

我该怎么做?在


Tags: unicodexe2绳子x80x9cx93x99xaa
1条回答
网友
1楼 · 发布于 2024-04-20 13:51:47

这个已经是UTF-8数据了;python向您展示了字符串文本形式。在

>>> print '\xe2\x80\x8e\xd7\x93\xd7\x9c\xd7\x99\xd7\xaa\xe2\x80\x8e'.decode('utf8')
‎דלית‎

上面的代码行将UTF-8数据解码为一个带有.decode('utf8') and prints that; theprintstatement inspects the encoding used by my terminal and re-encodes theunicode`对象的unicode对象,以便我的终端可以正确地显示它。在

您可能需要阅读Python和Unicode:

相关问题 更多 >