import json
with open('read.json', 'w') as outfile:
json.dump(data, outfile, sort_keys=True, indent=4)
# sort_keys, indent are optional and used for pretty-write
要从文件读取json:
with open('read.json') as data_file:
data = json.load(data_file)