老样子:先上代码

import xlrd

excel = xlrd.open_workbook("C:/Users/Administrator/Desktop/date.xls")  # 打开excel文件
sheet = excel.sheet_by_index(0)  # 获取工作薄


rows: list = sheet.row_values(0)  # 获取第一行的表头内容
index = rows.index('username')  # 获取age列所在的列数: 1,也可以换成"password"
listindes = sheet.col_values(index)  # 获取age列的所有内容

# 遍历该列所有的内容
for i in range(1, len(listindes)):
    print(listindes[i])

老样子:看效果

更多推荐

python怎么读取xls文件