When opening a file, what mode will you use to read the data from the file?
When opening a file, what mode will you use to read the data from the file?
a. mode = ‘b’
b. mode = ‘wb’
c. mode = ‘w’
d. mode = ‘r’
1 Answers
d. mode = ‘r’
Explanation:
‘r’: open for reading (default)
‘w’: open for writing, truncating the file first
‘x’: open for exclusive creation, failing if the file already exists
‘a’: open for writing, appending to the end of file if it exists
‘b’: binary mode
‘t’: text mode (default)
‘+’: open for updating (reading and writing)