Python_报错:EOFError: Ran out of input

Python 报错:EOFError: Ran out of input

    在运行序列化(pickle)相关功能时报错:EOFError: Ran out of input

 

上代码:

>>> import pickle
>>> s = pickle.load(fp)

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
EOFError: Ran out of input

原因分析:要用文件操作模式打开文件

解决

改成如下方法即可

>>> fp = open("a.txt","rb+")
>>> import pickle
>>> s = pickle.load(fp)#序列化打印结果
['apple', 'mango', 'carrot']
posted @ 2018-10-22 21:47  翻滚的小强  阅读(38284)  评论(0编辑  收藏  举报