defget_data(filename, sheetnum): dir_case = '123.xlsx' data = xlrd2.open_workbook(dir_case) table = data.sheets()[sheetnum] nor = table.nrows nol = table.ncols dict = {} for i inrange(1, nor): for j inrange(nol): title = table.cell_value(0, j) value = table.cell_value(i, j) dict[title] = value yielddict
if __name__ == '__main__': for i in get_data('add_user', 0): print(i)