English

Differentiate between 'w' and 'a' file modes in Python.

Advertisements

Question

Differentiate between 'w' and 'a' file modes in Python.

Distinguish Between
Advertisements

Solution

Here are the differences between 'w' and 'a' modes:

  1. 'w' or write mode. This opens the file for writing. If the file already exists, its contents are erased.
  2. 'a' mode or add mode. It opens the file to add extra data at the end while keeping previous information.
shaalaa.com
  Is there an error in this question or solution?
2023-2024 (March) Set 4

APPEARS IN

Advertisements
Share
Notifications



      Forgot password?
Use app×