python读写json文件
dump: 将数据写入json文件中
1 with open("../config/record.json","w") as f: 2 json.dump(new_dict,f) 3 print("加载入文件完成...")
load:把文件打开,并把字符串变换为数据类型
1 with open("../config/record.json",'r') as load_f: 2 load_dict = json.load(load_f) 3 print(load_dict) 4 load_dict['smallberg'] = [8200,{1:[['Python',81],['shirt',300]]}] 5 print(load_dict)