+ 8

What is pickling and unpickling?

26th Feb 2022, 2:38 PM
Vaibhav
Vaibhav - avatar
2 Answers
+ 2
Python pickle module is used for serializing and de-serializing python object structures. The process to converts any kind of python objects (list, dict, etc.) into byte streams (0s and 1s) is called pickling or serialization or flattening or marshalling. We can converts the byte stream (generated through pickling) back into python objects by a process called as unpickling. Example of pickling import pickle mylist = ['a', 'b', 'c', 'd'] with open('datafile.txt', 'wb') as fh: pickle.dump(mylist, fh) Example of unpickling import pickle pickle_off = open ("datafile.txt", "rb") emp = pickle.load(pickle_off) print(emp)
8th Jul 2022, 12:46 PM
😇🌟SWATI🌟😇
😇🌟SWATI🌟😇 - avatar