将返回的字典或者列表等数据写入json文件

import codes
import json

def write_json(self,result,json_name):
with codecs.open(json_name, "w", "utf-8") as f:
j = json.dumps(result, indent=4, ensure_ascii=False)
f.write(j)



posted @ 2021-01-18 10:50  fyangq  阅读(320)  评论(0编辑  收藏  举报