python通过open()打开文件不读取首行的实现方法
使用itertools包
from itertools import islice
data = open('data.csv', 'r')
# islice 第一个参数是要读取的文件,第二个参数说明从第几行开始读取,2 就是从第二行开始
for line in islice(data,2,None):
print(line)
data.close()
from itertools import islice
data = open('data.csv', 'r')
# islice 第一个参数是要读取的文件,第二个参数说明从第几行开始读取,2 就是从第二行开始
for line in islice(data,2,None):
print(line)
data.close()