更新时间:2023-09-17 23:33:04
使用切片,如下所示
with open('yourfile.txt') as f:
lines_after_17 = f.readlines()[17:]
如果文件太大量加载内存:
If the file is too big to load in memory:
with open('yourfile.txt') as f:
for _ in xrange(17):
next(f)
for line in f:
# do stuff