我正在嘗試創建一個字典,其中鍵是字符串,值是列表。類似的東西l1 = ['a', 'b', 'c']我想在 for 循環的每次迭代中添加類似于該列表的列表。我試過這個dicc['first'].append(l1)出口應該是這樣的:dicc={'first': ['a', 'b', 'c']}我總是得到同樣的錯誤: list indices must be integers or slices, not str我該怎么做?
添加回答
舉報
0/150
提交
取消