我试图读取一个列表中的嵌套列表,并将键和值添加到字典中的另一个字典中。但我得到了“str”对象不支持赋值的错误。
代码:
report_dict = dict()
axis_list = []
results = self.report_data(conn)
for row in results:
try:
report_dict[row[0]] = row[3]
report_dict[row[0]][row[3]] = row[1]
except IndexError:
None
print(report_dict)
结果:
report_dict = { abc: {qwe:asd}, …..}
results
的样例? - Wondercricket