类方法 就是针对 类对象的方法
在 类方法 的内部可以直接访问 类属性 或者调用其他的类方法
class TestMethod:
method = "方法"
def __init__(self,name):
print("这是个初始化方法")
self.name = name
def instance(self):
print("这是实例方法")
@classmethod
def kind(cls):
print("这是类%s" % cls.method)
def __del__(self):
print("对象销毁前使用的方法")
TestMethod.kind()
输出结果:这是类方法
类方法可以直接使用 类名.调用