When opening a file, the mode determines what you're allowed to do.
Mode Meaning
r π Read onlyw π Write (overwrites existing file)a π Append to the endx π Create a new filerb π Read binary fileswb π Write binary filesr+ π Read and writeπ Using the wrong mode is one of the easiest ways to accidentally erase a file.