展开全部
f = open ("7.txt",'r')
w = open ("11.txt",'a+')
while 1:
line = f.readline()
w.write(line)
print line
if not line:
break
如果你仔细阅读过官方文档的话, 你会发现open的定义open(file, mode=’r’, buffering=-1, encoding=None, errors=None, newline=None, closefd=True, opener=None)
buffering is an optional integer used to set the buffering policy. Pass 0 to switch buffering off (only allowed in binary mode), 1 to select line buffering (only usable in text mode), and an integer > 1 to indicate the size in bytes of a fixed-size chunk buffer. When no buffering argument is given, the default buffering policy works as follows:
buffering参数是一个整数用来设置缓冲e5a48de588b63231313335323631343130323136353331333363393035策略, 0 - 关闭缓冲(仅适用于二进制模式), 1 - 行缓冲(仅适用于文本模式), 如果整数大于1, 将按照整数的大小设置块缓冲区大小
默认的-1代表由系统处理
Binary files are buffered in fixed-size chunks; the size of the buffer is chosen using a heuristic trying to determine the underlying device’s “block size” and falling back on io.DEFAULT_BUFFER_SIZE. On many systems, the buffer will typically be 4096 or 8192 bytes long.
“Interactive” text files (files for which isatty() returns True) use line buffering. Other text files use the policy described above for binary files.