求Python获取Excel表格指定列中某几行的内容(如L4-L10)

图片说明如题,求Python获取Excel表格指定列中某几行的内容(如L4-L10)的方法,要考虑合并单元格的情况

有可能所在列的时间下为空,也可能有多个,也可能有合并单元格的情况,都要考虑在内,麻烦大家指点一二

import xlrd

excle = xlrd.open_workbook("hello.xlsx")

sheet = excle.sheets()[0]#获取第0个表

unit=sheet.row_values(3)

print(unit[2])

file_name = input("输入文件名:")+".xlsx"
table_number = int(input("输入表数:"))
col = int(input("输入指定列:"))-1
row = input("输入指定行(用空格隔开):")
def read_Excle(filename,tablenumber,col,row):
excle = xlrd.open_workbook(filename)
sheet = excle.sheets()[tablenumber]
row_list = row.split(" ")
if "-" in row:
row_list = row.split("-")
row_list = list(range(int(row_list[0]),(int(row_list[1])+1)))
for i in row_list:
print("第",end="")
print(int(i),end="")
print("行的值为:",end="")
print(sheet.cell(int(i)-1,col))
read_Excle(file_name,table_number,col,row)

合并单元格只是在直观上,实际并没有改变基本单元结构,并且python对于excle是根据有数据的最后一项设定列表范围的,
记得用pip引入第三方库xlrd 命令: pip installer xlrd