import pickle
...
man=[]
other=[]
with open('man.out','wb') as manOut , open('other.out','wb') as otherOut: #注意with后面的冒号
'''print(man,file=manOut)'''
'''print(other,file=otherOut)'''
pickle.dump(man,manOut) #将man变量中的数据写入到manOut中,即man.out文件
pickle.dump(other,otherOut)
with open('man.out','rb') as manRead: #从man.out文件读取数据
man_read = pickle.load(manRead)
Python文件读写
最新推荐文章于 2023-10-13 07:00:00 发布