xinggevip

Python(7-4)文件系统——pickle模块
pickle可以把任何数据保存文二进制文件和读取二进制文件>>> import pickle &...
扫描右侧二维码阅读全文
01
2018/12

Python(7-4)文件系统——pickle模块

pickle可以把任何数据保存文二进制文件和读取二进制文件

>>> import pickle
>>> pickle_file = open('D:\\A\\city_data.pkl','wb')
>>> city = {'河南':'123456','天津':'112233','菲律宾':'445566'}
>>> pickle.dump(city,pickle_file)
>>> pickle_file.close()
>>> pickle_file = open('D:\\A\\city_data.pkl','rb')
>>> city2 = pickle.load(pickle_file)
>>> city2
{'河南': '123456', '天津': '112233', '菲律宾': '445566'}
>>> 

更详细介绍:http://www.runoob.com/python3/python3-inputoutput.html

Last modification:December 1st, 2018 at 11:10 am
If you think my article is useful to you, please feel free to appreciate

Leave a Comment