美文网首页
Python Class

Python Class

作者: gengfo | 来源:发表于2020-03-29 17:13 被阅读0次
    # coding = utf-8
    class Game(object):
        top_score = 0
    
        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("%s 开始游戏啦..." % self.player_name)
    
    
    if __name__ == "__main__":
        Game.show_help()
    
        Game.show_top_score()
    
        game1 = Game("g1")
        game1.start_game()
    
    

    相关文章

      网友评论

          本文标题:Python Class

          本文链接:https://www.haomeiwen.com/subject/mmeuuhtx.html