class A:
@staticmethod
def a(): #静态方法不需要传参数
print ("this is a")
@classmethod
def b(cls): #第一个参数 习惯写成cls,打印出来是类
print(cls)
print ("this is b")
def c(self): #第一个参数,习惯写成self 表示实例化后的对象,打印出来是对象
print(self)
print ("this is c")
testa = A()
testa.a()
testa.b()
testa.c()
运行结果:
this is a
<class '__main__.A'>
this is b
<__main__.A object at 0x7f55e0f67b90>
this is c