python - 如何将二维列表中的值分配给变量
问题描述
我在 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]] ]
解决方案
推荐阅读
- octave - T(1.2):下标必须是整数 1 到 (2^63)-1 或逻辑
- c# - I'm having problems with async
- dolphindb - DolphinDB 中的哪个函数类似于 lag 操作?
- json - How to avoid double '\' escape when using serde_json in Rust?
- visual-studio - 使用 Visual Studio 编辑模型驱动的应用程序 Web 资源 (jscript)
- javascript - 幻灯片组件 Swiper 在 Javascript/CSS 中不起作用
- azure - 如何通过 C# 代码使用 Azure AD b2c 获取访问令牌?
- angular - Angular mat-table not filtering
- ruby-on-rails - Rails STI has_many STI children of one type
- java - Double 的 CBOR 编码给了我错误的输出