Advertisements
Advertisements
प्रश्न
Write the use and syntax for the following method:
dump()
टिप्पणी लिखिए
Advertisements
उत्तर
dump() method is used to convert (pickling) Python objects for writing data in a binary file. The file in which data are to be dumped, needs to be opened in binary write mode (wb).
Syntax of dump() is as follows:
dump(data_object, file_object)
where data_object is the object that has to be dumped to the file with the file handle named file_object.
1 import pickle
2 listavalues = [1, "Anjeev Singh", 'M', 36]
3 fileobject = open("mybinary.dat", "wb")
4 pickle.dump(listvalues, fileobject)
5 fileobject.close()shaalaa.com
The Pickle Module in Python
क्या इस प्रश्न या उत्तर में कोई त्रुटि है?
