import codesimport jsondef 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)
将返回的字典或者列表等数据写入json文件
原文:https://www.cnblogs.com/fyangq/p/14291639.html