import pickle
class Person():
def __init__(self,bank,telephone,month,money):
self.bank = bank
self.telephone = telephone
self.month=month
self.money=money
total=[]
with open("MR数据的统计.txt")as f:
file=f.read().splitlines()
print(file)
for i in file:
n=i.split("-")
lily=Person(n[1],n[0],n[2],n[3])
total.append(lily)
print(total)
'''
with open("C:/Users/1004-30/PycharmProjects/untitled1/mxc.txt","wb")as f2:
pickle.dump(total, f2)
'''
with open("C:/Users/1004-30/PycharmProjects/untitled1/mxc.txt","rb")as f2:
jieguo=pickle.load(f2)
print(jieguo[1].bank)
Python封装类序列化反序列化
最新推荐文章于 2022-04-07 19:57:03 发布