【发布时间】:2020-09-18 12:04:16
【问题描述】:
如图所示,我在一个文件中有一个普通文本,我想用 unicode 编写这样的文本
我有这段代码,但它没有做这项工作,它只是按原样编写文本,而我确实需要显示 utf-16 编码
with open(localOutputPath,'r') as infile:
data = infile.read()
#print(data)
with open(localUtf16Path, 'w', encoding="utf-16") as outfile:
outfile.write(data)
【问题讨论】:
-
您右侧的示例不是 UTF-16。那是 Unicode 转义序列。
-
你有那个脚本吗
标签: python character-encoding utf-16