Python print unicode list

后端 未结 1 1156
隐瞒了意图╮
隐瞒了意图╮ 2021-01-05 02:03

With the following code

lst = [u\'\\u5de5\', u\'\\u5de5\']
msg = repr(lst).decode(\'unicode-escape\')
print msg

I got

[u\'工         


        
相关标签:
1条回答
  • 2021-01-05 02:26
    >>> import sys
    >>> lst = [u'\u5de5', u'\u5de5']
    >>> msg = repr([x.encode(sys.stdout.encoding) for x in lst]).decode('string-escape')
    >>> print msg
    ['工', '工']
    
    0 讨论(0)
提交回复
热议问题