python中reader的next用法
python中有个csv包(build-in),该包有个reader,按行读取csv文件中的数据
reader.next()作用:打印csv文件中的第一行标题header
(python3中的用法)
allElectronicsData = open(r'C:/pydata/AllElectronics.csv', 'rt') reader = csv.reader(allElectronicsData) headers = next(reader)
(python2中的用法)
allElectronicsData = open(r'C:/pydata/AllElectronics.csv', 'rb') reader = csv.reader(allElectronicsData) headers = reader.next()
总结