Mode |
Description |
R |
Open the file in read-only mode. The file pointer will be placed at the beginning of the file. This is the default mode. |
Rb |
Open a file in binary format for read-only. The file pointer will be placed at the beginning of the file. This is the default mode. |
R + |
Open a file for reading and writing. The file pointer will be placed at the beginning of the file. |
Rb + |
Open a file in binary format for reading and writing. The file pointer will be placed at the beginning of the file. |
W |
Open a file for writing only. If the file already exists, overwrite it. If the file does not exist, create a new file. |
Wb |
Open a file in binary format for writing only. If the file already exists, overwrite it. If the file does not exist, create a new file. |
W + |
Open a file for reading and writing. If the file already exists, overwrite it. If the file does not exist, create a new file. |
Wb + |
Open a file in binary format for reading and writing. If the file already exists, overwrite it. If the file does not exist, create a new file. |
A |
Open a file for append. If the file already exists, the file pointer is placed at the end of the file. That is to say, the new content will be written to the existing content. If the file does not exist, create a new file for writing. |
AB |
Open a file in binary format for append. If the file already exists, the file pointer is placed at the end of the file. That is to say, the new content will be written to the existing content. If the file does not exist, create a new file for writing. |
A + |
Open a file for reading and writing. If the file already exists, the file pointer is placed at the end of the file. When the file is opened, the append mode is used. If the file does not exist, create a new file for reading and writing. |
AB + |
Open a file in binary format for append. If the file already exists, the file pointer is placed at the end of the file. If the file does not exist, create a new file for reading and writing. |