In examples of using pickle to save data, I often encounter a second parameter where many people use 'wb'
, for instance:
pickle.dump(obj, open('save.p', 'wb'))
.
What does the 'wb'
parameter do?
'wb' means 'write binary' and is used for the file handle: open('save.p', 'wb'
) which writes the pickeled data into a file.
The code you got is a short version of:
handle = open('save.p', 'wb')
pickle.dump(obj, handle)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With