When opening a file, what mode will you use to read the data from the file?

Questions & AnswersCategory: PythonWhen opening a file, what mode will you use to read the data from the file?
1 Answers
Geek Boy Staff answered 3 years ago

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)