在我的代码中,在调用new_week()时,“detentions”整数的值似乎是“day”整数的值。
我已经查看了代码,只是找不到导致它的原因。
其定义如下:
def new_week(self, detentions, motivation):
print(colored(detentions, 'yellow'))
oldmotiv = motivation
for i in range(0, detentions):
motivation = motivation - 3
print(colored("Detentions: " + str(detentions), 'yellow'))
print(colored("Motivation: " + str(motivation), 'yellow'))
print(colored("End of week summary: ", 'green'))
lostmotiv = oldmotiv - motivation
print(colored("You lost " + str(lostmotiv) + " motivation!", 'green'))
detentions = 0它被引用如下:
print("It's the weekend! What would you like to do?")
WorldSettings.new_week(detentions, day, motivation)
again = input("Continue? yes, no ")
again.lower()
day = 1发布于 2018-11-23 01:28:27
在您的代码中,调用方法就像调用类方法一样:
WorldSettings.new_week(detentions, day, motivation)它应该作为一个实例方法:
class_worldsettings.new_week(detentions, day, motivation)另外,请注意,您正在使用3个参数调用该方法,但是您的方法被定义为只需要2个参数(除了the `这是一个隐式参数):
def new_week(self, detentions, motivation)所以应该是:
def new_week(self, detentions, day, motivation)https://stackoverflow.com/questions/53439653
复制相似问题