English

Differentiate between r+ and w+ file modes in Python. - Computer Science (Python)

Advertisements
Advertisements

Question

Differentiate between r+ and w+ file modes in Python.

Distinguish Between

Solution

r+ mode:

  • Primary function is reading.
  • File pointer is at beginning of file.
  • if the file does not exist, it results in an error.

w+ mode:

  • primary function is writing.
  • If the file does not exist, it creates a new file.
  • If the file exists, previous data is overwritten.
  • File pointer is at the beginning of file.
shaalaa.com
Text File Open Modes
  Is there an error in this question or solution?
2023-2024 (March) Board Sample Paper
Share
Notifications

Englishहिंदीमराठी


      Forgot password?
Use app×