problem with pickle and tkinter

后端 未结 1 1348
忘了有多久
忘了有多久 2020-12-21 19:40

To learn tkinter I\'m making a simple Go game program. I now would like to be able to save a game using pickle, but when I try to pickle my GoBoardModel object

相关标签:
1条回答
  • 2020-12-21 20:28

    Yep, look into the __getstate__ method.

    For example, if you want pickle to ignore the 'view' attribute, you'd do the following:

    class Whatever(object):
    
      def __getstate__(self):
        state = self.__dict__.copy()
        del state['view']
        return state
    
    0 讨论(0)
提交回复
热议问题