封装类方法 调用类法例子class obj2: def __init__(self,name,age): self.Name=name self.Age=age; def adds(self): self.Age=self.Age+1 return self.Name,self.Age #print("%s 加" %self.Name) #self.Age=self.Age+1; import pickle obj=obj2(‘wangsan‘,1)#obj.adds();res=pickle.load(open("log.log","rb"))print(res.Age); #pickle.dump(obj,open("log.log","wb"));
时间: 2024-12-28 17:22:21