Access Modes#
The access mode parameter specifies the types of modifications that can be made to the file. It can also specify the type of data or information contained in the file.
Possible access mode parameters:
| Parameter | Name | Description |
|---|---|---|
"r" |
Read | Opens a file for reading; also the default value |
"a" |
Append | Opens the file for appending new or additional information; Creates the file if it does not already exist |
"w" |
Write | Opens the file for writing new information; Creates the file if it does not already exist |
"x" |
Create | Creates the file if it does not already exist |
Additionally, we can specify the type of data contained in the file, or how Python should handle the information in the file.
| Parameter | Name | Description |
|---|---|---|
"t" |
Text | Treats file as text data; also the default value |
"b" |
Binary | Treats the file as binary data |