Python - Pickling

The pickle module is used to complex data such as lists and dictionary. Text files are convenient to use because they can read, write and append using any code editor, but they are limited to storing a series of characters.

In simple terms, it is used for serialization. Serialization refers to the process of converting the object in memory to a byte stream that can be stored on the disk.

import pickle

The module should be imported for every program where the pickling should be applied.


The above statement is used to dump the data and store it into a file.

Sample Program

import pickle

name = ["Surya","Sushant","Nikita"]
skill = ["Data Scientist","Full Stack Developer","Software Developer"]

pickle_file = open("emp.txt","w")

In the program, there are two lists which are defined with data and should be dumped in the text file.

"w" is used to write the data into a file.

blog comments powered by Disqus