python 2.6 cPickle.load results in EOFError

时光怂恿深爱的人放手 提交于 2019-12-04 17:45:50

问题


I use cPickle to pickle a list of integers, using HIGHEST_PROTOCOL,

cPickle.dump(l, f, HIGHEST_PROTOCOL)

When I try to unpickle this using the following code, I get an EOFError. I tried 'seeking' to offset 0 before unpickling, but the error persists.

l = cPickle.load(f)

Any ideas?


回答1:


If you are on windows, make sure you

open(filename, 'wb') # for writing
open(filename, 'rb') # for reading


来源:https://stackoverflow.com/questions/2187558/python-2-6-cpickle-load-results-in-eoferror

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!