简体   繁体   English

TypeError:endturn()缺少1个必需的位置参数:'self'

[英]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.

相关问题 类型错误:kollision() 缺少 1 个必需的位置参数:'self' - TypeError : kollision() missing 1 required positional argument: 'self' TypeError:itertuples()缺少1个必需的位置参数:“ self” - TypeError: itertuples() missing 1 required positional argument: 'self' 类型错误:get() 缺少 1 个必需的位置参数:“self” - TypeError: get() missing 1 required positional argument: 'self' 类型错误:mainloop() 缺少 1 个必需的位置参数:'self' - TypeError: mainloop() missing 1 required positional argument: 'self' 类型错误:close() 缺少 1 个必需的位置参数:'self' - TypeError: close() missing 1 required positional argument: 'self' TypeError:PNI() 缺少 1 个必需的位置参数:'self' - TypeError: PNI() missing 1 required positional argument: 'self' TypeError: Missing 1 required positional argument: 'self' 有人吗? - TypeError: Missing 1 required positional argument: 'self' Anybody? 类型错误:gassens() 缺少 1 个必需的位置参数:'self' - TypeError: gassens() missing 1 required positional argument: 'self' 类型错误:缺少 1 个必需的位置参数:'self' - TypeError: Missing 1 required positional argument: 'self' TypeError:run() 缺少 1 个必需的位置参数:'self' - TypeError:run() missing 1 required positional argument: 'self'
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM