[英]TypeError: endturn() missing 1 required positional argument: 'self'
My class function is not working. 我的班级功能不起作用。 I am kind of new to classes and I am trying to understand the error message.
我是一个新的类,我试图理解错误信息。 I am not sure if i am going to put anything in the parameters?
我不确定我是否会在参数中添加任何内容?
class turns():
def endturn(self):
global movePoints
print("Turn Ended: \nRecruitment Report: {}".format(Recruited))
movePoints = 20
x = 50
y = 50
speed = 10
movePoints = 20
movePointLost = 1
Recruited = 0
turns.endturn()
You forgot to create an instance of your class 您忘了创建班级的实例
t = turns()
t.endturn()
Usually it doesn't make sense to call instance methods in the class directly. 通常直接调用类中的实例方法是没有意义的。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.