python将字典写入json文件

  • Post author:
  • Post category:python


1、python将字典数据写入json文件

import json

dict = {"key": "value"}
with open("dict.json", "w") as f:
	json_dict = json.dumps(dict)
	f.write(json_dict)

2、python读取json字典文件

import json

with open("dict.json", 'r+') as f:
	dict = json.load(f)



版权声明:本文为jason_cdd原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。