r Open text file for reading.
打开文本文件进行阅读。
The stream is positioned at the beginning of the file.
流位于文件的开头。
r+ Open for reading and writing.
打开(文件)进行阅读和写作。
The stream is positioned at the beginning of the file.
流位于文件的开头。
w Truncate file to zero length or create text file for writing.
将文件缩短为零长度(清空文件)或创建用于写入的文本文件。
The stream is positioned at the beginning of the file.
流位于文件的开头。
w+ Open for reading and writing.
打开(文件)进行阅读和写作。
The file is created if it does not exist, otherwise it is truncated.
如果文件不存在,则创建该文件,否则将其清空。
The stream is positioned at the beginning of the file.
流位于文件的开头。
a Open forappending(writing at end of file).
打开用于追加(在文件末尾写入)。
The file is created if it does not exist.
如果文件不存在,则创建该文件。
The stream is positioned at the end of the file.
流位于文件的末尾。
a+ Open for reading and appending(writing at end of file).
打开用于读取和追加(在文件末尾写入)。
The file is created if it does not exist.
如果文件不存在,则创建该文件。
The initial file position for reading is at the beginning of the file,
用于读取的初始文件位置是在文件的开头,
but output is always appended to the end of the file.
但是输出总是附加到文件的末尾。