shaoheshaohe 发表于 2020-5-25 17:05:26

python-本地读取和保存字典文件

dic = {'a': 1, 'b': 2, 'c': 3, 'd': 1}

# save to local
f = open("..\\data\\dict.txt", 'w')
f.write(str(dic))
f.close()
print("save dict successfully.")

# read from local
f = open("..\\data\\dict.txt", 'r')
dict_ = eval(f.read())
f.close()
print("read from local : ", dict_)


shaoheshaohe 发表于 2020-5-25 17:05:33

————————————————

https://blog.csdn.net/xidianbaby/java/article/details/86537871
页: [1]
查看完整版本: python-本地读取和保存字典文件