python通过文件操作字典
python把字典保存到文件中
python从文件中加载字典
import json my_dict = { 'Apple': 4, 'Banana': 2, 'Orange': 6, 'Grapes': 11,'area1':[[23,56],[66,12],[68,89],[90,890]]} # 保存文件 tf = open("myDictionary.json", "w") json.dump(my_dict,tf) tf.close() # 读取文件 tf = open("myDictionary.json", "r") new_dict = json.load(tf) print(new_dict) print(new_dict['area1'])
######################
标签:文件,python,json,dict,tf,字典 From: https://www.cnblogs.com/herd/p/17448606.html