- 序列化
>>> 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‘} >>>
时间: 2024-10-18 04:50:42