如何将二维列表中的值指定给变量B

2024-09-29 17:21:58 发布

您现在位置:Python中文网/ 问答频道 /正文

我正在用python为类编写2048,在尝试将sqaure[0]的值赋值给self.textCoordinates之后,我不断地得到错误'int' is not subscriptable,然后在下一行我得到相同的错误,在开始的行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]] ]

Tags: textinselfnonefor错误arrayint

热门问题