我按照下面的代码执行后显示这样的错误。
class Game(object):
top_score = 0
@staticmethod
def __init__(self, player_name):
self.player_name = player_name
@staticmethod
def show_help():
print("帮助信息:让僵尸进入大门")
@classmethod
def show_top_score(cls):
print("历史记录 %d" % cls.top_score)
def start_game(self):
print("开始游戏啦..." % self.player_name)
Game.show_help()
Game.show_top_score()
game = Game("小明")
game.start_game()
错误显示:
D:PY001venvScriptspython.exe D:/PY001/cards_main.py
帮助信息:让僵尸进入大门
Traceback (most recent call last):
历史记录 0
File "D:/PY001/cards_main.py", line 25, in <module>
game = Game("xiaoming")
TypeError: __init__() missing 1 required positional argument: 'player_name'
Process finished with exit code 1
请问怎么样修改才能解决这样的问题呢?
尚方宝剑之说
慕侠2389804
暮色呼如
相关分类