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:
['工', '工']
>>> import sys
>>> lst = [u'\u5de5', u'\u5de5']
>>> msg = repr([x.encode(sys.stdout.encoding) for x in lst]).decode('string-escape')
>>> print msg
['工', '工']
one more question?more_msg = ... just works. What is the problem?'ascii' codec can't decode byte is the error message.
AttributeError.u.for c in lst: print c.encode('utf-8')u. I just need the unicode characters in a tring withoutu. :)