from xlrd import open_workbook
book = open_workbook('Workbook2.csv')
sheet = book.sheet_by_index(0)
keys = [sheet.cell(0,col_index).value for col_index in xrange(sheet.ncols)]
dict_list =[]
for row_index in xrange(1,sheet.nrows):
d={keys[col_index]: sheet.cell(row_index, col_index).value for col_index in xrange(sheet.ncols)}
dict_list.append(d)
print dict_list
for i in range(len(dict_list)):
for key,val in dict_list[i]:
print val
试图打印出val,但它给出了这个错误:ValueError:太多的值来解压缩。任何人都可以帮忙?在这个错误上需要帮助:ValueError:太多的值来解压
'for key,val in dict_list [i] .items()'? –
CSV的内容是什么? – Rich