我有一个看起来很像的二维数组:
[[(0, 0), ('', 0), ('', 0), ('', 0), ('', 0), ('', 0)], [(0, 0), ('', 0), ('', 0), ('', 0), ('', 0), ('', 0)]]
我试图从给定的单元格中访问元组的值,如下所示:
x,y = self.cell_array[col][row]
它给了我这个错误:
TypeError: list indices must be integers, not str
我做错了什么?
答案 0 :(得分:3)
col和row的类型必须是int
取代:
x,y = self.cell_array[col][row]
为:
x,y = self.cell_array[int(col)][int(row)]