天天看點

python+selenium 讀取excel資料

讀取excel資料

#coding:utf-8

#導入excel讀方法包
import xlrd

#打開excel
excel=xlrd.open_workbook("C:\\Users\\Administrator\\Desktop\\test.xlsx")
#選擇Sheet
table=excel.sheet_by_name("Sheet1")

#擷取總行數
nrows=table.nrows
#擷取總列數
ncols=table.ncols

#讀取行資料
#print(table.row_values(0)) #讀取行之間資料

#周遊表所有的資料
for i in range(0,ncols+1):
    a = table.row_values(i)
    print(a)

#讀取指定行和列單個資料
print(table.cell_value(0,2))

#讀取列之間資料
print(table.col_values(0,2))



           

參考:https://blog.csdn.net/weixin_43577217/article/details/106717377