读取excel,目前比较会用的是xlrd,通过读取行数(rows)来获取每一行的值
import xlrd
xls = xlrd.open_workbook('33.xlsx')
sheet1 = xls.sheets()[0]
rows = sheet1.nrows
print('行数:',rows)
cols = sheet1.ncols
print('列数:',cols)
for i in range(0,rows):
name = sheet1.row_values(i)[0]
number = sheet1.row_values(i)[1]
pwd = sheet1.row_values(i)[2]
print(name,number,pwd)
>>
行数: 694
列数: 3
姓名 工号 密码
李薇茵-115140 115140.0 115140.0
夏梦林-110858 110858.0 110858.0
刘巧宾-111799 111799.0 111799.0
朱天霜-110948 110948.0 110948.0
陶帅军-110852 110852.0 110852.0
还需要学会xlwt:https://www.jianshu.com/p/fc97dd7e822c