Computer Science
Define pickling in Python. Explain serialization and deserialization of Python object.
Answer
The pickling process serializes objects and converts them into a byte stream so that they can be stored in binary files.
Serialization is the process of transforming data or an object in memory (RAM) into a stream of bytes called byte streams. These byte streams, in a binary file, can then be stored on a disk, in a database, or sent through a network. The serialization process is also called pickling. Deserialization or unpickling is the inverse of the pickling process, where a byte stream is converted back into a Python object.
Related Questions
Write a command(s) to write the following lines to the text file named hello.txt. Assume that the file is opened in append mode.
“ Welcome my class” “It is a fun place” “You will learn and play”
Write a Python program to open the file hello.txt used in question no 6 in read mode to display its contents. What will be the difference if the file was opened in write mode instead of append mode?
Write a program to accept string/sentences from the user till the user enters “END” to. Save the data in a text file and then display only those sentences which begin with an uppercase alphabet.
Write a program to enter the following records in a binary file :
Item No — integer
Item_Name — string
Qty — integer
Price — floatNumber of records to be entered should be accepted from the user. Read the file to display the records in the following format:
Item No :
Item Name :
Quantity :
Price per item :
Amount : ( to be calculated as Price * Qty)