Posted On: Feb 22, 2018
In Python Pickling is used for serializing objects in binary streams. Pickling can be performed on objects of data types like Booleans, Integers, Floats, Complex numbers, normal and Unicode Strings, Tuples, Lists, Sets, and Dictionaries.
UnPickling is reverse of the Pickling process, here binary streams have deserialized an object.
A simple example of Pickling and UnPickling In Python
import pickle // Pickling dogs_dict = { 'Ozzy': 3, 'Filou': 8, 'Luna': 5, 'Skippy': 10, 'Barco': 12, 'Balou': 9, 'Laika': 16 } filename = 'dogs' outfile = open(filename,'wb') pickle.dump(dogs_dict,outfile) outfile.close() // UnPickling infile = open(filename,'rb') new_dict = pickle.load(infile) infile.close()
Never Miss an Articles from us.
Java and Python are way different from each other, but both of them can be useful tools for high-tech developers. Also, ..
Python uses its own techniques to implement exception handling. <try-except> is the block that can be utilized by..
Modules can be defined as the Python files with an extension “.py”. The module name will be same as that of the fil..