- python 保存字典为json文件
# 方法1
json_str = json.dumps(all_house,ensure_ascii=False)
json_str = json.dumps(test_dict)
# 方法2
with open('test_data.json', 'w') as json_file:
json_file.write(json_str)
# 方法1
json_str = json.dumps(all_house,ensure_ascii=False)
json_str = json.dumps(test_dict)
# 方法2
with open('test_data.json', 'w') as json_file:
json_file.write(json_str)