美文网首页
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 - Extracting ZIP

    Zip format and Python ZipFile class class zipfile.ZipFile...

  • Fluent系列2

    First-Class Functions Functions in Python are first-class...

  • 2018-12-03 类class

    Python入门之类(class)

  • Python Note4 (OOP)

    Labels: Python, Class,Object Ref:Python Classes/Objects h...

  • class python

    If we wanted to extract a header, grab all the columns, a...

  • Python -- Class

    创建 Class 实例化 Class 传递 实例化后的 Class, 比如 bmw ,叫做对象;传递对象(及其他可...

  • python - class

    类的编码风格 1、类名应采用驼峰命名法 , 即将类名中的每个单词的首字母都大写, 而不使用下划线。 实例名和模块名...

  • Python class

    定义一个类 创建一个对象 Python会为你完成对象创建,然后你可以使用init()方法定制对象的初始化。 每个方...

  • python class

    instance variables and class variables @classmethod means...

  • 【Python】Class

    面对对象编程的三大特性:封装,继承,多态。 封装:create class class封装了Attribute和m...

网友评论

      本文标题:Python Class

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