如:{"电影":"阿凡达"}写入到数据库变成{'\xe7\x94\xb5\xe5\xbd\xb1': '\xe9\x98\xbf\xe5\x87\xa1\xe8\xbe\xbe'}
使用的办法
temp_dict={"电影":"阿凡达"} import json temp_dict=json.dumps(temp_dict) 写入数据库
实际结果是:
{'\xe7\x94\xb5\xe5\xbd\xb1': '\xe9\x98\xbf\xe5\x87\xa1\xe8\xbe\xbe'}
解决办法
temp_dict={"电影":"阿凡达"} import json temp_dict=json.dumps(temp_dict,ensure_ascii=False) 写入数据库