在Jupyter笔记本中打印汉字(Python 3)

2024-09-25 04:25:57 发布

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

我正在试着打印这个角色維 在Jupyter笔记本中。我可以用下面的代码来做

w = '\xe7\xb6\xad'

print( bytes(w, encoding='raw-unicode-escape').decode('utf-8') )

但是,我只有字符串z,其中

z = '\\xe7\\xb6\\xad'

从其他问题开始,我尝试了以下解决方案

print( bytes(z, encoding='raw-unicode-escape').decode('utf-8') )

print( z.encode('utf-8').decode('unicode_escape') )

import codecs
u = codecs.decode(z, 'raw-unicode-escape').encode('utf-8')
print(u)

print( str(u.decode('utf-8')) )

bytes( str(u.decode('utf-8')), encoding='raw-unicode-escape').decode('utf-8')

没有指纹維.

如何打印維 如果我只从z开始


Tags: 角色rawbytesunicodeutfencodingencodeprint