我正在尝试创建一个字典,其中键是字符串,值是列表。类似的东西
l1 = ['a', 'b', 'c']
我想在 for 循环的每次迭代中添加类似于该列表的列表。
我试过这个
dicc['first'].append(l1)
出口应该是这样的:
dicc={'first': ['a', 'b', 'c']}
我总是得到同样的错误: list indices must be integers or slices, not str
list indices must be integers or slices, not str
我该怎么做?
萧十郎
相关分类