with open(filename, 'rb') as f:
for line in f:
<do something with the line>
构造可迭代对象 f,进行迭代遍历:for line in f,会自动地使用缓冲IO(buffered IO)以及内存管理,而不必担心任何大文件的问题。
with open(filename, 'rb') as f:
for line in f:
<do something with the line>
构造可迭代对象 f,进行迭代遍历:for line in f,会自动地使用缓冲IO(buffered IO)以及内存管理,而不必担心任何大文件的问题。
本文标题:读取大文件
本文链接:https://www.haomeiwen.com/subject/jkofmftx.html
网友评论