【发布时间】:2021-11-29 11:26:00
【问题描述】:
为什么会抛出异常 TypeError: 'method' object is not subscriptable?我怎样才能解决这个问题?希望你能帮我 随机导入
enemies = ["Scorpion","Zombie","Spider","Bat","Boar"]
enemy = enemies(random.choice[enemies])
【问题讨论】:
-
应该是
random.choice(enemies)。注意括号而不是括号。
标签: python arrays list exception