Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Python Pickle Dump 'Wb' parameter

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?

like image 226
Max Chang Avatar asked Dec 05 '16 19:12

Max Chang


1 Answers

'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)
like image 178
Maurice Meyer Avatar answered Sep 30 '22 13:09

Maurice Meyer