Skip to content

Instantly share code, notes, and snippets.

@sharnie
Created May 26, 2014 15:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sharnie/09bbc95cdf62d11d4c02 to your computer and use it in GitHub Desktop.
Save sharnie/09bbc95cdf62d11d4c02 to your computer and use it in GitHub Desktop.
r
Read-only mode. The file pointer is placed at the beginning of the file. This is the default mode.
r+
Read-write mode. The file pointer will be at the beginning of the file.
w
Write-only mode. Overwrites the file if the file exists. If the file does not exist, creates a new file for writing.
w+
Read-write mode. Overwrites the existing file if the file exists. If the file does not exist, creates a new file for reading and writing.
a
Write-only mode. The file pointer is at the end of the file if the file exists. That is, the file is in the append mode. If the file does not exist, it creates a new file for writing.
a+
Read and write mode. The file pointer is at the end of the file if the file exists. The file opens in the append mode. If the file does not exist, it creates a new file for reading and writing.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment