with open('data', 'w') as f:
pickle.dumps({'foo':111},f)
results in
an integer is required (got type _io.TextIOWrapper)
How can I fix this?
I am pretty sure An integer is required? open() was not called beforehand.
Python version is 3.6.2
with open('data', 'w') as f:
pickle.dumps({'foo':111},f)
results in
an integer is required (got type _io.TextIOWrapper)
How can I fix this?
I am pretty sure An integer is required? open() was not called beforehand.
Python version is 3.6.2
pickle.dumps dumps obj into a string which it returns. In order to write into a file, you probably want to use pickle.dump (without the s).
with open('data', 'wb') as f:
pickle.dump({'foo':111}, f)
Additionally you should also open the file in binary mode, because pickle.dump will write binary data.