python 从第二行开始读文件

python 从第二行开始读文件

filename = info.txt
f = open('info.txt')
next(f)
for line in f:
print(line)

next()函数获取了第一行的数据,但没有做任何动作。这样其后的FOR循环就直接从第二行开始读取执行。

猜你喜欢

转载自www.cnblogs.com/ChenYi0919/p/8856553.html