Today, when debugging the program, I encountered a coding problem. After tossing for a long time, I saw a blog: Click to open the link to solve the problem. Now the excerpt is as follows, so as to avoid the same problem in the future.
In python below a list (list) or dictionary containing Chinese strings, using print directly will produce the following results:
dict = {"asdf": "Our python study"}
print dict
{'asdf': '\xe6\x88\x91\xe4\xbb\xac\xe7\x9a\x84python\xe5\xad\xa6\xe4\xb9 \xa0'}
is very inconvenient when outputting the processed data structure, you need to use the following method to output:
import json
print json.dumps(dict, encoding="UTF-8", ensure_ascii=False)
{"asdf": "our python learning"}