English

Tabulate the different modes with their meaning.

Advertisements

Question

Tabulate the different modes with their meaning.

Long Answer
Advertisements

Solution

Mode Description
‘r’ Open a file for reading (default).
‘w’ Open a file for writing. Creates a new file if it does not exist or truncates the file if it exists.
‘x’ Open a file for exclusive creation. If the file already exists, the operation fails.
‘a’ Open for appending at the end of the file without truncating it. Creates a new file if it does not exist.
‘t’ Open in text mode, default.
‘b’ Open in binary mode.
‘+’ Open a file for updating (reading and Writing).
shaalaa.com
Introduction to Python and CSV Files
  Is there an error in this question or solution?
Chapter 13: Python and CSV files - Evaluation [Page 266]
Advertisements
Share
Notifications



      Forgot password?
Use app×