मराठी

Write the file mode that will be used for opening the following file. Also, write the Python statement to open the following file: a text file “example.txt” in both read and write mode

Advertisements
Advertisements

प्रश्न

Write the file mode that will be used for opening the following file. Also, write the Python statement to open the following file:

a text file “example.txt” in both read and write mode

टीपा लिहा
Advertisements

उत्तर

The mode that will be used for opening given file is -

Read and Write (<r+> or <+r>) : This mode is used to open the file for reading and writing. The File Offset is positioned at the beginning of the file. It will raise an I/O error if the file does not exists.

Example - file = open("example.txt","r+")
          file.close()
shaalaa.com
Types of Files in Python
  या प्रश्नात किंवा उत्तरात काही त्रुटी आहे का?
पाठ 2: File Handling in Python - Exercise [पृष्ठ ३७]

APPEARS IN

एनसीईआरटी Computer Science [English] Class 12
पाठ 2 File Handling in Python
Exercise | Q 3. a) | पृष्ठ ३७
Share
Notifications

Englishहिंदीमराठी


      Forgot password?
Use app×