Unpickle sometimes makes blank objects
问题 I'm trying to use pickle to save a custom class; something very much like the code below (though with a few methods defined on the class, and several more dicts and such for data). However, often when I run this, pickle and then unpickle, I lose whatever data was in the class, and its as if I created a new blank instance. import pickle class MyClass: VERSION = 1 some_data = {} more_data = set() def save(self,filename): with open(filename, 'wb') as f: p = pickle.Pickler(f) p.dump(self) def