pickle.dump(object,file,protocol) #To serialize an object
pickle.load(file) #To de-serialize an object
pickle.dumps(object, protocol) # To serialize an object to bytes
pickle.loads(buffer) # To de-serialzie an object from bytes
|object||The object which is to be stored|
|file||The open file which will contain the object|
|protocol||The protocol used for pickling the object (optional parameter)|
|buffer||A bytes object that contains a serialized object|
The following objects are picklable.
dicts containing only picklable objects
__dict__or the result of calling
__getstate__()is picklable (see the official docs for details).
Based on the official Python documentation.
The pickle module is not secure. It should not be used when receiving the serialized data from an untrusted party, such as over the Internet.