首页 > 解决方案 > 如何将二维列表中的值分配给变量

问题描述

我在 python 中为类编写 2048 ,'int' is not subscriptable在尝试分配 to 的值后sqaure[0]我一直收到错误self.textCoordinates,然后在下一行我得到同样的错误,然后在开始的行再次出现self.textColour

def updateWindow(self):
    for row in gme.array:
        for square in row:
            self.textCoordinates = square[0]
            self.text = str(square[1])
            if self.text != "None":
                self.textColour = gme.colourArray[gme.numArray.index(square[1])]
                self.drawUpdate()

    updateCanvas()   

的值为gme.array

    self.array = [ [[[100,100], None], [[300,100], None], [[500,100], None], [[700,100], None]],
                   [[[100,300], None], [[300,300], None], [[500,300], None], [[700,300], None]],
                   [[[100,500], None], [[300,500], None], [[500,500], None], [[700,500], None]],
                   [[[100,700], None], [[300,700], None], [[500,700], None], [[700,700], None]] ]

标签: pythonlistint

解决方案


推荐阅读