微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

如何从精灵组中选择特定的精灵?

如何解决如何从精灵组中选择特定的精灵?

所以我一直在尝试为一个游戏项目创建一个迷宫布局,我希望能够从一个精灵组中选择一个特定的精灵,精灵没有一个特定的变量名,因为我已经使用了循环创建 80 个精灵。我想使用该组中的 1 个精灵作为起始位置,并在函数的参数中使用它来返回该“单元格”。但是,通过执行 find_cell((cells[0],"east"),'cells' 作为精灵组,我收到一条错误消息:“TypeError: 'Group' object is not subscriptable”,这意味着我不能使用 [ ]. 我想知道有没有办法从精灵组中选择一个特定的精灵。

代码

定义 Main():

WARNING: Value for scheme.headers does not match. Please report this to <https://github.com/pypa/pip/issues/9617>
distutils: /Users/<user>/.pyenv/versions/3.9.4/include/python3.9/UNKNowN
sysconfig: /Users/<user>/.pyenv/versions/3.9.4/include/python3.9
WARNING: Additional context:
user = False
home = None
root = None
prefix = None
Requirement already satisfied: Flake8 in ./.pyenv/versions/3.9.4/lib/python3.9/site-packages (3.9.1)
Requirement already satisfied: mccabe<0.7.0,>=0.6.0 in ./.pyenv/versions/3.9.4/lib/python3.9/site-packages (from Flake8) (0.6.1)
Collecting pyflakes<2.4.0,>=2.3.0
  Using cached pyflakes-2.3.1-py2.py3-none-any.whl (68 kB)
Requirement already satisfied: pycodestyle<2.8.0,>=2.7.0 in ./.pyenv/versions/3.9.4/lib/python3.9/site-packages (from Flake8) (2.7.0)
Installing collected packages: pyflakes
WARNING: Value for scheme.headers does not match. Please report this to <https://github.com/pypa/pip/issues/9617>
distutils: /Users/<user>/.pyenv/versions/3.9.4/include/python3.9/UNKNowN
sysconfig: /Users/<user>/.pyenv/versions/3.9.4/include/python3.9
WARNING: Additional context:
user = False
home = None
root = None
prefix = None
Successfully installed pyflakes-2.3.1

错误: 第 56 行,在 Main find_cell(细胞[0],“东”) 类型错误:“组”对象不可下标

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。