类方法&实例方法&静态方法

class S():
    def __init__(self, a):
        self.a = a

    def x(self):
        print('a is', self.a)

    @classmethod
    def b(*args):
        print('arg is', args)

    @classmethod
    def c(cls):
        print('cls is', cls)

    @staticmethod
    def d(*args):
        print('arg is', args)


s = S(10)
s.x()
s.b()
s.d()
s.c()

# a is 10
# arg is (<class '__main__.S'>,)
# arg is ()
# cls is <class '__main__.S'>
抟扶摇而上者九万里
原文地址:https://www.cnblogs.com/fengting0913/p/13598725.html