the dump method accepts an object to be written and file-like object to write the serialized bytes to this object must have write method (or it wouldn' be file-like)and that method must know how to handle bytes argument (so file opened for text output wouldn' workthe load method does exactly the oppositeit reads serialized object from file-like object this object must have the proper file-like read and readline argumentseach of which mustof coursereturn bytes the pickle module will load the object from these bytes and the load method will return the fully reconstructed object here' an example that stores and then loads some data in list objectimport pickle some_data [" list""containing" "values including another list"["inner""list"]with open("pickled_list"'wb'as filepickle dump(some_datafilewith open("pickled_list"'rb'as fileloaded_data pickle load(fileprint(loaded_dataassert loaded_data =some_data this code works as advertisedthe objects are stored in the file and then loaded from the same file in each casewe open the file using with statement so that it is automatically closed the file is first opened for writing and then second time for readingdepending on whether we are storing or loading data the assert statement at the end would raise an error if the newly loaded object is not equal to the original object equality does not imply that they are the same object indeedif we print the id(of both objectswe would discover they are different howeverbecause they are both lists whose contents are equalthe two lists are also considered equal the dumps and loads functions behave much like their file-like counterpartsexcept they return or accept bytes instead of file-like objects the dumps function requires only one argumentthe object to be storedand it returns serialized bytes object the loads function requires bytes object and returns the restored object the 'scharacter in the method names is short for stringit' legacy name from ancient versions of pythonwhere str objects were used instead of bytes