面向对象:类方法、静态方法、实例方法

class Test(object):
    x = 11
    def __init__(self, _x):
        self._x = _x
        print("Test.__init__")
 
    @classmethod
    def class_method(cls):  # 类方法
        print("class_method")
 
    @staticmethod
    def static_method():  # 静态方法
        print("static_method")
 
    @classmethod
    def getPt(cls):
        cls.class_method()
        cls.static_method()

 

posted @ 2017-02-13 11:40  hutzerg  阅读(156)  评论(0编辑  收藏  举报