Python 退出应用程序时的Pickle将引发AttributeError

Python 退出应用程序时的Pickle将引发AttributeError,python,pyqt,pyside,Python,Pyqt,Pyside,我试图在主应用程序关闭后pickle一个类实例,但我得到了 Exception AttributeError: "'NoneType' object has no attribute 'dump'" in <bound method MainFrame.__del__ of <__main__.MainFrame object at 0x03BA6508>> ignored 的两种方法都会产生相同的错误 我该怎么做呢?除非你真的、真的知道自己在做什么,否则不要使用 如果

我试图在主应用程序关闭后pickle一个类实例,但我得到了

Exception AttributeError: "'NoneType' object has no attribute 'dump'" in <bound method MainFrame.__del__ of <__main__.MainFrame object at 0x03BA6508>> ignored
的两种方法都会产生相同的错误

我该怎么做呢?

除非你真的、真的知道自己在做什么,否则不要使用

如果要在退出时保存内容,请重新实现主窗口:

class MainFrame(QWidget):
    ...

    def closeEvent(self, event):
        pickle.dump(progress, open("pickle_file.p", "wb"))            

加1链接到
\uuu del\uuu
class MainFrame(QWidget):
    ...

    def closeEvent(self, event):
        pickle.dump(progress, open("pickle_file.p", "wb"))