如果您从文件中读取它,只需在打开时提供编码:
with open('test.txt', encoding='unipre-escape') as f: a = f.read()print(a)# choice = 選択用
test.txt含有:
选择= u9078 u629e
如果您已经在字符串中输入了文本,则可以这样进行转换:
a = "choice = \u9078\u629e"a.enpre().depre('unipre-escape')# 'choice = 選択'
如果您从文件中读取它,只需在打开时提供编码:
with open('test.txt', encoding='unipre-escape') as f: a = f.read()print(a)# choice = 選択用
test.txt含有:
选择= u9078 u629e
如果您已经在字符串中输入了文本,则可以这样进行转换:
a = "choice = \u9078\u629e"a.enpre().depre('unipre-escape')# 'choice = 選択'