When you open file like that:
f = open("demofile.txt", "r")
f.write("Something")
There are some in which you can open file.
"r" Opens a file for reading only.
"r+" Opens a file for both reading and writing.
"rb" Opens a file for reading only in binary format.
"rb+" Opens a file for both reading and writing in binary format.
"w" Opens a file for writing only.
"a" Open for writing. The file is created if it does not exist.
"a+" Open for reading and writing. The file is created if it does not exist.
"x" Creates a new file. If file already exists, the operation fails.
"t" This is the default mode. It opens in text mode.
"b" This opens in binary mode.
"+" This will open a file for reading and writing (updating)