温馨提示×

python怎么遍历excel表格

养鱼的猫咪
3441
2021-03-08 11:40:02
栏目: 编程语言
Python开发者专用服务器限时活动,0元免费领,库存有限,领完即止! 点击查看>>

python怎么遍历excel表格

在python中使用xlrd模块对excel表格进行遍历,具体方法如下:

import xlrd #导入xlrd模块

bok = xlrd.open_workbook(r'E:\temp\xxxx.xlsx') #excel表格路径

sht = bok.sheets()[0]

row =sht.nrows

for i in range(row):

rowdate = sht.row_values(i)#i行的list

for a,b in enumerate(rowdate):

print(i,a,b) #第i行,a列,数据b

亿速云「云服务器」,即开即用、新一代英特尔至强铂金CPU、三副本存储NVMe SSD云盘,价格低至29元/月。点击查看>>

推荐阅读:怎么用python处理excel表格数据

1