使用DictReader时,如何跳过CSV中的一行记录?
码:
import csv reader = csv.DictReader(open('test2.csv')) # Skip first line reader.next() for row in reader: print(row)
错误:
Traceback (most recent call last): File "learn.py", line 3, in <module> reader.next() AttributeError: 'DictReader' object has no attribute 'next'
您next(reader)改为使用。
next(reader)
来源:csv.DictReader文档