标签:self sel 实例化 pen init path with pat 对象
import pickle
class Mypickle:
def __init__(self,path):
self.file = path
def dump(self,obj):
with open(self.file, ‘ab‘) as f:
pickle.dump(obj, f)
def load(self):
with open(self.file,‘rb‘) as f:
while True:
try:
yield pickle.load(f)
except EOFError:
break
a=A(‘cat‘,1)
s=Mypickle(‘file‘)
s.dump(a)
s.load()
标签:self sel 实例化 pen init path with pat 对象
原文地址:https://www.cnblogs.com/diracy/p/13440230.html