python中使用pyexcel操作excel方法
2017-08-03 18:15
579 查看
python中使用pyexcel操作excel方法
安装:pip install pyexcel理解pyexcel中 book ,sheet,record的关系
pyexcel中 book ,sheet,record的关系
book是一本书,sheet是书里的一页,record是页面上的记录。所以在excel的世界里book就是一份.xlsx文件,而sheet是这个文件的每个sheet页签,record是每个页签的记录python代码块
import pyexcel as pe def run(): filename = 'sales.xlsx' book = pe.get_book(file_name=filename) for sheet in book: # 循环xlsx文件中的每个sheet页 print sheet.name # 这就是你自己xlsx文件命名的sheet页名称 sheet.name_columns_by_row(0) # 把每个sheet页的第一行作为列名 records = sheet.to_records() # 获取sheet页中所有的记录 for record in records: phone = unicode(record[u'手机号']) # 通过列名就能获取数据 print phone
相关文章推荐
- Python使用xlrd模块操作Excel数据导入的方法
- Python使用xlwt模块操作Excel的方法详解
- python操作excel的方法(xlsxwriter包的使用)
- Python使用xlrd模块操作Excel数据导入的方法
- Python使用xlrd模块操作Excel数据导入的方法
- Python使用xlrd模块操作Excel数据导入的方法
- 使用Python2.7操作Selenium2时只打开浏览器不load URL的解决方法
- python操作Excel读写--使用xlrd
- Python 使用xlrd模块操作Excel写
- python操作Excel读写--使用xlrd
- python操作Excel读写--使用xlrd
- python操作Excel读写(使用xlrd和xlrt)
- python操作Excel读写(使用xlrd和xlrt)
- python操作Excel读写--使用xlrd
- python操作Excel读写--使用xlrd
- python操作Excel读写--使用xlrd
- python操作Excel读写--使用xlrd
- python操作Excel读写(使用xlrd和xlrt)
- Memcached 安装、使用(Python操作)以及常用方法
- python操作Excel读写--使用xlrd