📌  相关文章
📜  TypeError: can't pickle weakref objects site:stackoverflow.com - Python 代码示例

📅  最后修改于: 2022-03-11 14:45:26.054000             🧑  作者: Mango

代码示例1
>>> import dill
>>> import weakref
>>> dill.loads(dill.dumps(weakref.WeakKeyDictionary()))

>>> dill.loads(dill.dumps(weakref.WeakValueDictionary()))

>>> class _class:
...   def _method(self):
...     pass
... 
>>> _instance = _class()
>>> dill.loads(dill.dumps(weakref.ref(_instance)))

>>> dill.loads(dill.dumps(weakref.ref(_class())))

>>> dill.loads(dill.dumps(weakref.proxy(_instance)))

>>> dill.loads(dill.dumps(weakref.proxy(_class())))