Mode Description
r Read-only. Starts at the beginning of the file (default mode).
r+ Read-write. Starts at the beginning of the file.
w Write-only. Truncates existing file to zero length or creates a new file for writing.
w+ Read-write. Truncates existing file to zero length or creates a new file for reading and writing.
a Write-only. Starts at the end of file if the file exists, otherwise creates a new file for writing.
a+ Read-write. Starts at the end of the file if the file exists, otherwise creates a new file for reading and writing.
b (DOS/Windows only.) Binary file mode. May appear with any of the modes listed in this table.
|