Computer Science
Which of the following functions do you use to write data in the binary format ?
- write()
- output()
- dump()
- send()
Python File Handling
3 Likes
Answer
dump()
Reason — To write an object on to a binary file opened in the write mode, we should use dump() function of pickle module as per following syntax: pickle.dump(<object-to-be-written>, <file-handle-of-open-file>)
.
Answered By
2 Likes
Related Questions
Which of the following command is used to open a file "c:\pat.txt" for writing in binary format only ?
- fout = open("c:\pat.txt", "w")
- fout = open("c:\\pat.txt", "wb")
- fout = open("c:\pat.txt", "w+")
- fout = open("c:\\pat.txt", "wb+")
Which of the following command is used to open a file "c:\pat.txt" for writing as well as reading in binary format only ?
- fout = open("c:\pat.txt", "w")
- fout = open("c:\\pat.txt", "wb")
- fout = open("c:\pat.txt", "w+")
- fout = open("c:\\pat.txt", "wb+")
Which of the following option is the correct usage for the tell() of a file object ?
- It places the file pointer at a desired offset in a file.
- It returns the entire content of a file.
- It returns the byte position of the file pointer as an integer.
- It tells the details about the file.
Which of the following statement is incorrect in the context of pickled binary files ?
- The csv module is used for reading and writing objects in binary files.
- The pickle module is used for reading and writing objects in binary files.
- The load() of the pickle module is used to read objects.
- The dump() of the pickle module is used to write objects.