Simple example of use of __setstate__ and __getstate__

前端 未结 3 1605
夕颜
夕颜 2020-12-02 10:27

I don\'t know what the __setstate__ and __getstate__ methods do, so help me with a simple example.

3条回答
  •  半阙折子戏
    2020-12-02 10:38

    These methods are used for controlling how objects are pickled and unpickled by the pickle module. This is usually handled automatically, so unless you need to override how a class is pickled or unpickled you shouldn't need to worry about it.

提交回复
热议问题