Before that lets see the File Modes in Python
File Modes in Python
|
|
Mode
|
Description
|
'r' |
Open a file for reading. (by default) |
'w' |
Open a file for writing. Creates a new file if it does not
exist or deleates the file if it exists. |
'x' |
Open a file for exclusive creation. If the file already exists,
the operation fails. |
'a' |
Open for appending at the end of the file without replacing it.
Creates a new file if it does not exist. |
't' |
Open in text mode. (by default) |
'b'
|
Open in binary mode. |
'+'
|
Open a file for updating (reading and writing) |