python读取excel
python是什么?python又该如何读取excel?python读取excel我们采用xlrd这个库进行读写,下面给大家带来详细的使用方法
第一步打开cmd输入以下命令
pipinstallxlrd
等待下载结束
第二步创建准备读取excel的副本对象
alfilename=xlrd.open_workbook("目标产物.xlsx")
第三步获取该excel中对应的sheet
dsq_sheet=dsq_xls.sheets()[0]
第四步读取行列数据
row_value=dsq_sheet.row_values(0)#获取某行数据col_value=dsq_sheet.col_values(0)#获取某列数据#获取某单元格数据value=dsq_sheet.row_values(row_num)[col_num].valuevalue=dsq_sheet.col_values(col_num)[row_num].valuevalue=dsq_sheet.cell(row_num,col_num).value