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']
原文地址:https://www.cnblogs.com/rychh/p/9833318.html