#方式一:直接加载显示ascii形式的内存加载
dictx = {"商家名称": "井格老灶火锅(望京新世界店)", "评分": 26.2, "地址": "火锅望京广顺南大街路16号", "人均消费": 105, "评论数量": 1387}
info = json.dumps(dictx)
print(info)
#方式二:中文编码显示需要转换加载方式
info = json.dumps(dictx, indent=4, ensure_ascii=False)
info = info.encode("gb2312").decode("gbk")
print(info)
打印结果:
{"\u5546\u5bb6\u540d\u79f0": "\u4e95\u683c\u8001\u7076\u706b\u9505(\u671b\u4eac\u65b0\u4e16\u754c\u5e97)", "\u8bc4\u5206": 26.2, "\u5730\u5740": "\u706b\u9505\u671b\u4eac\u5e7f\u987a\u5357\u5927\u8857\u8def16\u53f7", "\u4eba\u5747\u6d88\u8d39": 105, "\u8bc4\u8bba\u6570\u91cf": 1387}
{
"商家名称": "井格老灶火锅(望京新世界店)",
"评分": 26.2,
"地址": "火锅望京广顺南大街路16号",
"人均消费": 105,
"评论数量": 1387
}