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
प्रश्न
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
क्या इस प्रश्न या उत्तर में कोई त्रुटि है?
