python文件操作:pickle模块多次dump后出现的读取问题

 

在学习pickle的过程中遇到了多次dump后的读取问题,在网上找到如下解决办法:

import pickle

a=1
b=2
c=3with open("ceshi.txt","wb") as f:
    pickle.dump(a,f)
    pickle.dump(b,f)
    pickle.dump(c,f)

f=open("ceshi.txt","rb")
with open("ceshi.txt","rb") as f :
   while True:
        try:
            print(pickle.load(f))
        except:

#后续进行的操作
        break

 

你可能感兴趣的:(Python)