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()APPEARS IN
संबंधित प्रश्न
Which of the following modes is used for both writing and reading from a binary file?
Which of the following modes is used for both writing and reading from a binary file?
What is not true for binary files?
Which is not an encoding scheme for storing text file?
Every line of text file terminates with a special character called ______.
If you open a binary file you will see ______.
Trying to open a binary file using a text editor will show:
File that requires specific programs to access its contents.
Differentiate between text file and binary file.
Write the file mode that will be used for opening the following file. Also, write the Python statement to open the following file:
a binary file “bfile.dat” in write mode.
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 “try.txt” in append and read mode.
Write the file mode that will be used for opening the following file. Also, write the Python statement to open the following file:
a binary file “btry.dat” in read only mode.
Assertion (A): CSV (Comma Separated Values) is a file format for data storage that looks like a text file.
Reason (R): The information is organized with one record on each line and each field is separated by a comma.
Write one difference between CSV and text files.
How are text files different from binary files?
