首页 > 解决方案 > AttributeError:“NoneType”对象在类对象列表中没有属性“n”

问题描述

哦,那是真的。现在该代码有效,但我的长代码仍然无效。这是https://pastebin.com/Z4qjGxCU。这个问题是,当我在瓷砖上调用 check_num() 时,它可以工作。但是当我调用 check_mouse()、load_image() [我已经评论过,因此您不必下载资产] 或 print_tile() 时,它们会返回如下错误:

Traceback (most recent call last):
  File "C:\Users\sergio\Desktop\Minesweeper\minesweeper.py", line 96, in <module>
    grid[i][j].check_mouse()
AttributeError: 'Tile' object has no attribute 'check_mouse'

我检查了代码,但我找不到任何错误的地方。有任何想法吗?

标签: pythonpython-3.xpygame

解决方案


class A:用代替定义一个类def A()


推荐阅读