使用切片,如下所示:
with open('yourfile.txt') as f: lines_after_17 = f.readlines()[17:]
如果文件太大而无法加载到内存中:
with open('yourfile.txt') as f: for _ in range(17): next(f) for line in f: # do stuff
欢迎分享,转载请注明来源:内存溢出
使用切片,如下所示:
with open('yourfile.txt') as f: lines_after_17 = f.readlines()[17:]
如果文件太大而无法加载到内存中:
with open('yourfile.txt') as f: for _ in range(17): next(f) for line in f: # do stuff
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)