这个问题可能看起来有点基础,但无法找到我在互联网上理解的任何内容.如何储存我用莳萝腌制的东西?
我来这里是为了保存我的构造(pandas DataFrame,它也包含自定义类):
import dill
dill_file = open("data/2017-02-10_21:43_resultstatsDF", "wb")
dill_file.write(dill.dumps(resultstatsDF))
dill_file.close()
Run Code Online (Sandbox Code Playgroud)
和阅读
dill_file = open("data/2017-02-10_21:43_resultstatsDF", "rb")
resultstatsDF_out = dill.load(dill_file.read())
dill_file.close()
Run Code Online (Sandbox Code Playgroud)
但我在阅读时得到了错误
TypeError: file must have 'read' and 'readline' attributes
Run Code Online (Sandbox Code Playgroud)
我该怎么做呢?