-
江户川乱折腾
with open(fname) as f: next(f) for line in f: #do something
-
MMMHUHU
f = open(fname,'r')lines = f.readlines()[1:]f.close()
-
largeQ
如果要第一行,然后要对文件执行一些操作,此代码将很有帮助。with open(filename , 'r') as f: first_line = f.readline() for line in f: # Perform some operations
-
万千封印
如果切片可以在迭代器上工作...from itertools import islicewith open(fname) as f: for line in islice(f, 1, None): pass