时间:2022-05-28 08:45:55 | 栏目:Python代码 | 点击:次
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()
总结