天天看点

python中读取execl、xlrd

import xlrd

book = xlrd.open_workbook('CJ_test.xls')
sheet = book.sheet_by_index(0)
print(sheet.row_values(0))  # 某一行的数据
print(sheet.col_values(0))  # 某一列的数据
print(sheet.cell(0, 0).value)  # 某个单元格的数据
print(sheet.cell(1, 2).value)  # 某个单元格的数据
print(sheet.nrows)  # 总共有多少行
print(sheet.ncols)  # 总共有多少列
# 整行的数据
# 整列的数据
# 某个单元格

# sheet = book.sheet_by_name()

for i in range(sheet.nrows):
    print(sheet.row_values(i))      

转载于:https://www.cnblogs.com/skyxiuli/p/10858945.html