The python pickle module implements basic data sequence and deserialization.
We were able to save through the serialization of objects pickle module runs the program information to a file to permanent storage.
By deserialization operations pickle module, we were able to create the last saved program object from the file.
Objects - "File
Import pickle # using the pickle module to save the data object to a file DATAl = { ' A ' : [. 1, 2.0,. 3,. 4 + 6J ], ' B ' : ( ' String ' , U ' the Unicode String ' ), ' C ' : None} selfref_list = [. 1, 2,. 3 ] selfref_list.append (selfref_list) Output = Open ( ' data.pkl ' , ' WB ' ) # Pickle Protocol of 0. The Dictionary the using the pickle.dump (DATAl,output) # Pickle the list using the highest protocol available. pickle.dump(selfref_list, output, -1) output.close()
File - "Object
Import the pprint, pickle # using the pickle module python reconstructed object from the file pkl_file = Open ( ' data.pkl ' , ' RB ' ) DATAl = the pickle.load (pkl_file) pprint.pprint (DATAl) DATA2 = the pickle.load (pkl_file ) pprint.pprint (data2) pkl_file.close ()