In python, the list, of print "list composed of unicode" only shows unicode code.

problem description

create a list:
test= [[u "test", u "learn"], [u "ask", u "answer"]
and then print with print with the display of
[uu6d4bu8bd5, uu5b66u4e60"], [uu63d0u95eebread, uu56deu7b54"]

.

the environmental background of the problems and what methods you have tried

found some methods on the Internet, such as ".join (XXX), encode.decode, etc., but failed

.

related codes

/ / Please paste the code text below (do not replace the code with pictures)
test= [[u "test", u "learn"], [u "ask", u "answer"]
print test

what result do you expect? What is the error message actually seen?

look forward to seeing [["testing", "learning"], ["asking", "answering"]
, however, what is actually output is [upliu6d4bu8bd5percent, upliu5b66u4e60"], [upliu63d0u95eebread, upliu56deu7b54"]

.
Mar.25,2021

the coding problem of python2 is really a headache.
for your situation, you should first convert the unicode type to utf-8 format for display.

-sharp coding: utf-8

test=[[u'',u''],[u'',u'']]
-sharp  utf-8 
tester = [[y.encode('utf-8') for y in x] for x in test]

-sharp print 
print(repr(tester).decode('string-escape'))

using python3, these similar coding problems will hardly occur.



>>> test=[[u'',u''],[u'',u'']]           
>>> print(test)
[['', ''], ['', '']]
>>> 

Python3 does not need any action at all. Haha

Menu