fileInput 由一个大约 30 行的 csv 文件组成,我只想访问第二行。
for row in csv.reader(fileInput):
我需要访问第二行而不是第一行(第一行包含列名称)。 row[1]
给出 row0
中的第二列?
仅第二行而不是第一行!
最佳答案
r = csv.reader(f)
first_line = next(r)
second_line = next(r)
for line in r:
print(line) #rest of the lines
reader
返回一个迭代器:https://docs.python.org/3/library/csv.html#csv.reader
关于Python:只执行一次for循环(不是第一次,而是第二次)?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40347570/