写文件,格式化
indent
: 缩进(一般填4,缩进4格);sort_keys
: 是否排序(默认False
–不排序)
1
2
3
4
5
6
7 def write_info(file_name, file_info):
with open('{}.json'.format(file_name), 'w') as fp:
json.dump(file_info, fp, indent=4, sort_keys=True)
write_info('report', dict(report_data))
import json