扫描二维码下载沐宇APP

沐宇

微信扫码使用沐宇小程序

沐宇

python怎么遍历excel表格

扬州沐宇科技
2021-03-08 11:40:02
excel, python, 遍历

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

扫码添加客服微信