import xlrdfrom xlutils.copy import copydef read_data(): wb=xlrd.open_workbook("数据汇总.xls") sh=wb.sheet_by_index(0) count_price=[] fen_type={} for r in range(sh.nrows): count=sh.cell_value(r,3)*sh.cell_value(r,4) count_price.append(count) key=sh.cell_value(r,0) ####这个逻辑非常难,如果正常做是要把fen_type直接喂给第一列,但是我们更想得到一个字典,让A:xxx,b:xxx if fen_type.get(key): fen_type[key]+=count else: fen_type[key]=count ###测试代码中给喂的值一定要return return fen_type,count_pricedef save_data(fen,count): wb=xlrd.open_workbook("数据汇总.xls") sh_t=wb.sheet_by_index(0) wb2=copy(wb) sh=wb2.get_sheet(0) sh2=wb2.add_sheet("汇总的数据") for r in range(sh_t.nrows): sh.write(r,sh_t.ncols,count[r]) for i,key in range(fen.keys()): sh2.write(i,0,key) sh2.write(i,1,fen.values(key)) wb2.save("汇总数据1.xlsx")if __name__=="__main__": f,c=read_data() save_data(f,c)Traceback (most recent call last): File "C:/Users/ALIENWARE/PycharmProjects/baizhanchengxuyuan/数据汇总.py", line 36, in save_data(f,c) File "C:/Users/ALIENWARE/PycharmProjects/baizhanchengxuyuan/数据汇总.py", line 28, in save_data sh.write(r,sh_t.ncols,count[r])IndexError: list index out of range老师请问出现这个错误是怎么回事