python-3.x - TypeError:“列表”对象不可调用 - 类编码
解决方案
方法名和列表名都是动作。当其初始化的 self.actions(method) 被 self.actions(list) 替换时。列表不可调用
class Troll:
def __init__(self):
self.name = ''
self.phrases = ['Pass the ball','SHOOT']
self.available_actions = ['passes the ball','shoots']
def speak(self):
print(self.name, "shouts", random.choice(self.phrases))
def actions(self):
print(self.name,"decides to", self.available_actions)
推荐阅读
- unity3d - 统一游戏不能作为可执行文件运行
- javascript - 检查对象数组是否包含一个值
- git - 致命:无法创建工作树目录“SaloonApp。”:无效参数
- javascript - 如何使用 php 将表格中的数据显示到表单输入中(完整/准确描述向下)
- debugging - VSCode 调试在调试 Rust 库时显示所有断点的“位置:0”
- google-cloud-functions - Google 功能无法在云计算中打开和关闭 vm 实例
- javascript - 我似乎无法在我的图书馆应用程序上使用切换开关
- android - 所以我目前正在尝试将应用程序上传到 PlayStore,但我需要将我的 react native 项目从 api lvl 28 升级到 29
- go - golang:嵌套结构到嵌套 json 或 json
- python - Dialogflow api检测意图在Windows上不起作用