序列化
>>> import pickle >>> >>> f = open("user_acc.txt","wb") >>> >>> info = { ... "alex":"123", ... "jack":"4444" ... } >>> >>> f.write(pickle.dumps(info)) 51 >>> >>> f.close() >>> >>> f = open("user_acc.txt","rb") >>> data_from_atm = pickle.loads(f.read()) >>> print(type(data_from_atm)) <class ‘dict‘> >>> print(data_from_atm) {‘jack‘: ‘4444‘, ‘alex‘: ‘123‘} >>>
本文出自 “AMY” 博客,请务必保留此出处http://amy2015.blog.51cto.com/11407620/1770269
原文地址:http://amy2015.blog.51cto.com/11407620/1770269