python中reader的next用法
2018-07-24 14:19
836 查看
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()
总结
以上所述是小编给大家介绍的python中reader的next用法,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对脚本之家网站的支持!
您可能感兴趣的文章:
相关文章推荐
- Python问题:AttributeError: '_csv.reader' object has no attribute 'next' 以及UnicodeDecodeError: 'gbk' co
- python “AttributeError: '_csv.reader' object has no attribute'next'” 报错的解决办法
- python3中的read中的next用法注意
- python某些语句的用法
- python-pandas的基本用法10
- Python中*args用法
- Python中optparser库用法实例详解
- Python中numpy.clip();numpy.fabs()的用法;以及math.pow()的说明
- InputStreamReader和BufferedReader用法及实例讲解
- python中maketrans和translate的用法
- 浅谈python jieba分词模块的基本用法
- python中assert用法实例分析
- Python 入门:字符串连接及join用法
- Python中的else的特殊用法
- Python 进阶----*args和 **kwargs,装饰器 的用法
- python中的next()以及iter()函数
- python map和reduce的用法
- 芝麻HTTP: Python爬虫利器之Requests库的用法
- python中-args 和--kwargs的用法
- Python中int()函数的用法浅析