Computer Science
Answer
The differences between "w" and "a" modes are:
"w" mode | "a" mode |
---|---|
The "w" mode in file opening is used for writing data to a file. | The "a" mode in file opening is used for appending data to a file. |
If the file exists, Python will truncate existing data and over-write in the file. | If the file exists, the data in the file is retained and new data being written will be appended to the end of the file. |
Related Questions
Assertion. Every open file maintains a file-pointer and keeps track of its position after every operation.
Reason. Every read and write operation takes place at the current position of the file pointer.
Assertion. CSV (Comma Separated Values) is a file format for data storage which looks like a text file.
Reason. The information is organized with one record on each line and each field is separated by comma.
What is the significance of a file-object ?
How is file open() function different from close() function?