我按照下面的代碼執(zhí)行后顯示這樣的錯誤。class Game(object):
top_score = 0
@staticmethod
def __init__(self, player_name):
self.player_name = player_name
@staticmethod
def show_help():
print("幫助信息:讓僵尸進(jìn)入大門")
@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幫助信息:讓僵尸進(jìn)入大門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
請問怎么樣修改才能解決這樣的問題呢?
關(guān)于在python3.7當(dāng)中的語法錯誤!
繁星點(diǎn)點(diǎn)滴滴
2019-02-20 02:48:36