The string pointed to by mode determines how the file will be opened. The following table shows the legal values for mode. (Strings like ?+b?may also be represented as ?b+.?
Mode Meaning
r Open a text file for reading.
w Create a text file for writing.
a Append to a text file.
rb Open a binary file for reading.
wb Create a binary file for writing.
ab Append to a binary file.
r+ Open a text file for read/write.
w+ Create a text file for read/write.
a+ Append or create a text file for read/write.
r+b Open a binary file for read/write.
w+b Create a binary file for read/write.
a+b Append or create a binary file for read/write.
Related examples in the same category