# xlrd -- excel转字典
import xlrd
def get_data(sheet1):
data = xlrd.open_workbook('data.xls')
table = data.sheets()[0]
# print(table)
nor = table.nrows
nol = table.ncols
dict = {}
for i in range(1,nor):
for j in range(nol):
title = table.cell_value(0,j)
value = table.cell_value(i,j)
dict[title] = value
yield dict
if __name__ == '__main__':
for i in get_data(0):
print(i)
Python语言xlrd -- excel转字典
于 2023-12-01 00:35:09 首次发布