[Solved] Python error: EOFError: Ran out of input

Python error: EOFError: Ran out of input

Error when running pickle-related functions: EOFError: Ran out of input

Previous code.

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

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

Cause analysis: to open a file in file operation mode

Solution:

Change to the following method

>>> fp = open("a.txt","rb+")
>>> import pickle
>>> s = pickle.load(fp)#Serialized Print Results
['apple', 'mango', 'carrot']

 

Similar Posts: