python读取json文件
import json
def read(name):
with open(f'common/data/{name}.json', encoding='UTF-8') as json_file:
return json.load(json_file)
read(a)
python写入json文件
import json
test_dict = {
'version': "1.0",
'results': 'video',
'explain': {
'used': True,
'details': "this is for josn test",
}
}
json_str = json.dumps(test_dict, indent=4)
with open('test_data.json', 'w') as json_file:
json_file.write(json_str)