import json
py_dict = {}
josn_str = json.dumps(py_dict)
josn_str = json.dumps(py_dict,ensure_ascii=False)
可能需要注意中文编码问题,ensure_ascii=False,否则写入文件后中文可能是ASCII编码
import json
py_dict = [{},{},{},,,,]
josn_str = json.dump(py_dict,open('save.json', 'w', encoding='utf-8'),ensure_ascii=False)
or
with open('save.json', 'w', encoding='utf-8')as f:
josn_str = json.dump(py_dict,f,ensure_ascii=False)
json.dump(序列化对象,文件句柄,ensure_ascii=False)
文件以UTF-8编码打开,dump()也加上ensure_ascii=False,否则写入文件后中文可能是ASCII编码
https://www.cnblogs.com/mingjiatang/p/9527345.html 中文编码问题
https://www.cnblogs.com/autobyme/p/11011451.html
https://blog.csdn.net/liuxiao214/article/details/80115924
import json
json_str = '[{},{},{},,,,]'
py_dict = json.loads(json_str)
import json
py_dict = json.load(open('data.json','r'))
or
with open('data.json','r')as f:
py_dict = json.load(f)
https://www.xjh.me/3034.html?replytocom=4430
https://www.cnblogs.com/gracejiang/p/6398703.html
https://blog.csdn.net/Scrat_Kong/article/details/82049052