我在变量中使用unicode。我想把它的中国价值储存在variab中

2024-09-30 01:21:42 发布

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

我如何储存中国价值观(漢字漢字漢字) 在变量中

 x = u'\u6f22\u5b57\u6f22\u5b57\u6f22\u5b57'
 x
u'\u6f22\u5b57\u6f22\u5b57\u6f22\u5b57'
 print x
漢字漢字漢字
 y = str(x)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
UnicodeEncodeError: 'ascii' codec can't encode characters in position 0-5: ordinal not in range(128)

Tags: inmoststdinlinecallfilelastprint

热门问题