简体   繁体   English

EOFError打开/读取腌制的文件

[英]EOFError Opening/Reading Pickled File

so I have a pickled file that I would like to read and display the data from. 所以我有一个腌制的文件,我想从中读取和显示数据。 I've never worked with pickled files before, but from a little research I found simple commands that should open it properly. 我以前从未使用过腌制的文件,但是通过一些研究,我发现了应该正确打开它的简单命令。 Unfortunately I receive some errors that I will display below: 不幸的是,我收到一些错误,将在下面显示:

import pickle

f = open("1965.pkl")

here = pickle.load(f)
Traceback (most recent call last):

  File "<ipython-input-7-43273f8d751b>", line 1, in <module>
    here = pickle.load(f)

  File "D:\Anaconda\lib\pickle.py", line 1378, in load
    return Unpickler(file).load()

  File "D:\Anaconda\lib\pickle.py", line 858, in load
    dispatch[key](self)

  File "D:\Anaconda\lib\pickle.py", line 880, in load_eof
    raise EOFError

EOFError

Not really sure what this issue is since the EOFError doesn't give its usual description. 由于EOFError未给出其通常的说明,因此无法确定该问题是什么。

Any help is a big thanks! 任何帮助都非常感谢!

Try this : 尝试这个 :

   here = pickle.load(open("1965.pkl", 'rb'))

[ Edit ]: [编辑]:

Or you wrote to pickle with wrong flag. 否则您写的泡菜标志错误。

For writing you should use 'wb'; 编写时应使用“ wb”; for reading 'rb' 用于阅读“ rb”

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM