Modes |
Description |
“r” |
It opens a file in read mode for reading. File to read must exist. |
“r+” |
It opens a file for both reading and writing. File must exist. |
“w” |
It opens a file in write mode for writing. A file is created if it does not but if it exists its contents are overwritten |
“w+” |
Open a file for both reading and writing. A file is created if it does not exist but if it exists its contents are overwritten. |
“a” |
It opens a file in append mode. It adds the contents at the end of file. |
“a+” |
Opens a file for both reading and appending. |