我試圖在一個模塊中醃製一個類的實例,並在另一個模塊中取出它。取出對象時出現AttributeError
這裏就是我醃製:
import cPickle
def pickleObject():
object = Foo()
savefile = open('path/to/file', 'w')
cPickle.dump(object, savefile, cPickle.HIGHEST_PROTOCOL)
class Foo(object):
(...)
這裏的地方我嘗試unpickle:
savefile = open('path/to/file', 'r')
object = cPickle.load(savefile)
,第二行上,我得到AttributeError: 'module' object has no attribute 'Foo'
任何人都看到我在做什麼錯誤?
這樣做。感謝您的幫助,夥計們。 – Max 2010-09-01 02:02:57