Python Creating Dictionary from excel data

后端 未结 6 720
梦毁少年i
梦毁少年i 2020-11-30 08:48

I want to create a dictionary from the values, i get from excel cells, My code is below,

wb = xlrd.open_workbook(\'foo.xls\')
sh = wb.sheet_by_index(2)   
f         


        
6条回答
  •  南方客
    南方客 (楼主)
    2020-11-30 09:45

    d = {}
    wb = xlrd.open_workbook('foo.xls')
    sh = wb.sheet_by_index(2)   
    for i in range(138):
        cell_value_class = sh.cell(i,2).value
        cell_value_id = sh.cell(i,0).value
        d[cell_value_class] = cell_value_id
    

提交回复
热议问题