The problem of Chinese display from Python Dictionary to json string

use the json.dumps method to convert the dictionary to json string, which is not displayed in Chinese. ensure_ascii is set to False

.

clipboard.png

the converted string is:

{"first": {"value": "\xe8\xae\xa2\xe5\x8d\x95\xe9\x80\x9a\xe7\x9f\xa5", "color": "-sharp173177"}, "keyword1": {"value": "201804271644432959", "color": "-sharp173177"}, "keyword2": {"value": "\xe8\xae\xa2\xe5\x8d\x95\xe9\xa2\x84\xe5\xae\x9a\xe6\x88\x90\xe5\x8a\x9f", "color": "-sharp173177"}, "keyword3": {"value": "2018-04-27 16:44:43", "color": "-sharp173177"}, "remark": {"value": "\xe6\x81\xad\xe5\x96\x9c\xe6\x82\xa8\xef\xbc\x8c\xe8\xae\xa2\xe5\x8d\x95\xe9\xa2\x84\xe5\xae\x9a\xe6\x88\x90\xe5\x8a\x9f\xef\xbc\x8c\xe6\x82\xa8\xe5\x8f\xaf\xe4\xbb\xa5\xe7\x82\xb9\xe5\x87\xbb\xe6\x9f\xa5\xe7\x9c\x8b\xe6\xad\xa4\xe8\xae\xa2\xe5\x8d\x95\xe8\xaf\xa6\xe6\x83\x85", "color": "-sharp000000"}}

Python version 3. 6
look it up on the Internet, but there is no answer

ask the bosses to tell you the reasons and solutions

Mar.06,2021
When

dumps, json data is unicode encoded by default, so non-English characters are displayed in unicode encoding, but the content is not affected. Your python is 2.7?


things like 'xe8xaexa2xe5x8dx95xe9x80x9axe7x9fxa5'' are generally gbk or utf-8 Chinese codes.
can be decoded with gbk or utf-8. Depending on the format declared by the code, there are 2 bytes in gbk and 3 bytes in utf-8.
you can see from the figure that the Chinese word for 'xe8xaexa2xe5x8dx95xe9x80x9axe7x9fxa5'12 bytes' is the order notice, which is decoded in utf-8, and then the Chinese code of unicode in json. Can be decoded with unicode_escape.
the figure is as follows:

Menu