直接上代码吧
def writejson2file(data, filename):
with open(filename, 'w',encoding='utf8') as outfile:
data = json.dumps(data, indent=4, ensure_ascii=False)
outfile.write(data)
def readjson(filename):
with open(filename,'rb') as outfile:
return json.load(outfile)