我有一个简单的
python脚本输出到author.json文件.问题是它不包含文件末尾的换行符.
#!/usr/bin/env python import json with open('input.json','r') as handle: data = json.load(handle) output = open('author.json','w') author = {} for key,value in data.items(): if key == 'id': author['id'] = value output.write(json.dumps(author,indent=4))