Different modes for opening a file are tabulated below:
| Modes | Operations |
| “r” | Open text file for reading |
| “w” | Open text file for writing, previous content, if any, discarded |
| “a” | Open or create file for writing at the end of the file |
| “r+” | Open text file for update |
| “w+” | Create or open text file for update, previous content lost, if any |
| “a+” | Open or create text file for update, writing at the end. |