在另一个项目中解开具有类定义的对象

时间:2019-05-10 13:18:46

标签: python-3.x pickle

所以我有一个在其他项目中被腌制的对象,即DataFile。说

class DataFile(Filetype):
    """ Implts the persistent data format definition """
    def __init__(self, filepath):
        super().__init__()
        self.df = None
        self.data = None
        self.parse_df(filepath)

我想在另一个项目中对此进行修复。我知道类定义不会随对象一起使用,因此我需要在打开的项目中可以访问类定义。为了进行快速测试,我将DataFile(和Filetype)类定义放入了导入项目的文件中。

但是,当我到达那一行时

with open(filepath, 'rb') as f:
    df = pickle.load(f)

我仍然“未能解释为泡菜”。怎么来的?我尝试调试pickle.load()调用,但是它可能是c隐式且非常不透明。感谢您的帮助,

0 个答案:

没有答案
相关问题