【发布时间】:2016-06-07 21:45:40
【问题描述】:
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: too many values to unpack。有谁可以帮忙?
【问题讨论】:
-
for key,val in dict_list[i].items()? -
CSV 的内容是什么?
标签: python