将返回的字典或者列表等数据写入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)



原文地址:https://www.cnblogs.com/fyangq/p/14291639.html