Python: Pickle.Load() Raising Eoferror

python: pickle.load() raising EOFError

To load data, wouldn't you want to be reading data ("rb") instead of writing data ("wb")?

Loading data should look like this:

 with open("C:/Users/Lab Komputasi/Documents/estu/filenamereal1.txt", "rb") as f:
data = pickle.load(f)

Also, using f.close() is unnecessary because you are using a with/as clause.

pickle.load() raising EOFError in Windows

Always use b mode when reading and writing pickles (open(f, 'wb') for writing, open(f, 'rb') for reading). To "fix" the file you already have, convert its newlines using dos2unix.

EOFError using pickle.load()

If you only have one dump call, you should only have one load call.

with open(filename, 'r') as f:
pos = pickle.load(f)

Python: EOF error in pickle.load

From the looks of it your cookie_store.dat file is currently empty, because you are trying to load prior to saving the cookies on the following lines:

r = requests.post(url, data, cookies=load_cookies('cookie_store.dat'))
save_cookies(r.cookies, 'cookie_store.dat')


Related Topics



Leave a reply



Submit