我正在尝试加载json文件.更新它并将其写回.这是我的尝试,但我收到一个错误:
TypeError: dump() takes at least 2 arguments (1 given)
with open('employees.json') as data_file: employees = json.load(data_file) data_file.close employees['employees'].append({ "id": "2","name": "Rob Croft","key": "0003837852"}) with open('employees.json','w') as data_file: json.dump(employees) data_file.close