您可以
seek将文件放入文件,然后从那里读取一定数量。Seek允许您获取文件中的特定偏移量,然后可以将读取限制为该范围内的字节数。
with open(filename) as fin: fin.seek(start_index) data = fin.read(end_index - start_index)
那只会读取您要查找的数据。

您可以
seek将文件放入文件,然后从那里读取一定数量。Seek允许您获取文件中的特定偏移量,然后可以将读取限制为该范围内的字节数。
with open(filename) as fin: fin.seek(start_index) data = fin.read(end_index - start_index)
那只会读取您要查找的数据。