[英]Python print unicode list
With the following code 使用以下代码
lst = [u'\u5de5', u'\u5de5']
msg = repr(lst).decode('unicode-escape')
print msg
I got 我有
[u'工', u'工']
How can I remove the leading u
so that the content of msg
is: 如何删除前导u
以使msg
的内容为:
['工', '工']
>>> import sys
>>> lst = [u'\u5de5', u'\u5de5']
>>> msg = repr([x.encode(sys.stdout.encoding) for x in lst]).decode('string-escape')
>>> print msg
['工', '工']
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.