2017-05-19 回答
r表示只读,b表示二进制
与此对应的是w表示可写,t表示文本方式打开。
再增加一些官方的解释:
>>> print file.__doc__
file(name[, mode[, buffering]]) -> file object
open a file. the mode can be 'r', 'w' or 'a' for reading (default),
writing or appending. the file will be created if it doesn't exist
when opened for writing or appending; it will be truncated when
opened for writing. add a 'b' to the mode for binary files.
add a '+' to the mode to allow simultaneous reading and writing.
if the buffering argument is given, 0 means unbuffered, 1 means line
buffered, and larger numbers specify the buffer size. the preferred way
to open a file is with the builtin open() function.
add a 'u' to mode to open the file for input with universal newline
support. any line ending in the input file will be seen as a '\n'
in python. also, a file so opened gains the attribute 'newlines';
the value for this attribute is one of none (no newline read yet),
'\r', '\n', '\r\n' or a tuple containing all the newline types seen.