任何有效的方式来创build从单元格列表的Python范围?

我有一个Excel文件,我有一些参数,我需要返回特定的单元格区域,但不同的行。

def get_list(row, start, stop): arr = list[start:stop] #and somewhere here I need to iterate throgh row because I store row separately. 

有什么build议么? 谢谢!

您可以通过以下function的范围。 我在这里使用xlrd。

 import xlrd def excel_reader(excel_name): wb = xlrd.open_workbook(excel_name) sh = wb.sheet_by_index(0) for i in range(sh.nrows): if i > 0: cell_value_class = int(sh.cell_value(i, 0)) cell_value_id = int(sh.cell_value(i, 1)) DataList[cell_value_class] = cell_value_id