所以我创建了一个书类并将它的实例添加到我试图腌制的列表中,但我遇到了一个奇怪的错误。帮助表示赞赏!
with open("book_data/books.pkl", "wb") as f:
pickle.dump(book_list, f)
输出:
PicklingError Traceback (most recent call last)
<ipython-input-24-45ad0cec62df> in <module>
1 with open("book_data/books.pkl", "wb") as f:
2
----> 3 pickle.dump(book_list, f)
PicklingError: Can't pickle <class '__main__.book'>: it's not the same object as __main__.book