str(dic).decode(“string_escape”) 即可
例如
dic原本应该显示的格式:
{‘新疆干部群众热议《新疆的若干历史问题》白皮书’: '{“loc”: “http://xj.people.com.cn/n2/2019/0725/c186332-33179522.html”, “pub_time”: 1564022460, “docid”: “e64c11fbf69e1b791e4ebf4e52f04376”, “author”: “unknown”, “title”: “新疆干部群众热议《新疆的若干历史问题》白皮书”, “url”: “http://xj.people.com.cn/n2/2019/0725/c186332-33179522.html”, “publisher”: “”, “area”: [“新疆”], “content”: “新疆干部群众热议《新疆的>若干历史问题》白皮书–新疆频道–人民网”, “pub_type”: “news”, “crawler_tm”: 1576398300}
现在dic乱码显示为:
‘\xe6\x96\xb0\xe7\x96\x86\xe5\xb9\xb2\xe9\x83\xa8\xe7\xbe\xa4\xe4\xbc\x97\xe7\x83\xad\xe8\xae\xae\xe3\x80\x8a\xe6\x96\xb0\xe7\x96\x86\xe7\x9a\x84\xe8\x8b\xa5\xe5\xb9\xb2\xe5\x8e\x86\xe5\x8f\xb2\xe9\x97\xae\xe9\xa2\x98\xe3\x80\x8b\xe7\x99\xbd\xe7\x9a\xae\xe4\xb9\xa6’: ‘{“loc”: “http://xj.people.com.cn/n2/2019/0725/c186332-33179522.html”, “pub_time”: 1564022460, “docid”: “e64c11fbf69e1b791e4ebf4e52f04376”, “author”: “unknown”, “title”: “\xe6\x96\xb0\xe7\x96\x86\xe5\xb9\xb2\xe9\x83\xa8\xe7\xbe\xa4\xe4\xbc\x97\xe7\x83\xad\xe8\xae\xae\xe3\x80\x8a\xe6\x96\xb0\xe7\x96\x86\xe7\x9a\x84\xe8\x8b\xa5\xe5\xb9\xb2\xe5\x8e\x86\xe5\x8f\xb2\xe9\x97\xae\xe9\xa2\x98\xe3\x80\x8b\xe7\x99\xbd\xe7\x9a\xae\xe4\xb9\xa6”, “url”: “http://xj.people.com.cn/n2/2019/0725/c186332-33179522.html”, “publisher”: “”, “area”: ["\xe6\x96\xb0\xe7\x96\x86"], “content”: “\xe6\x96\xb0\xe7\x96\x86\xe5\xb9\xb2\xe9\x83\xa8\xe7\xbe\xa4\xe4\xbc\x97\xe7\x83\xad\xe8\xae\xae\xe3\x80\x8a\xe6\x96\xb0\xe7\x96\x86\xe7\x9a\x84\xe8\x8b\xa5\xe5\xb9\xb2\xe5\x8e\x86\xe5\x8f\xb2\xe9\x97\xae\xe9\xa2\x98\xe3\x80\x8b\xe7\x99\xbd\xe7\x9a\xae\xe4\xb9\xa6–\xe6\x96\xb0\xe7\x96\x86\xe9\xa2\x91\xe9\x81\x93–\xe4\xba\xba\xe6\xb0\x91\xe7\xbd\x91”, “pub_type”: “news”, “crawler_tm”: 1576398300}’}
解决方法:
str(dic).decode(“string_escape”) #dic是要显示的字典/列表,验证显示正确