python中静态方法与类方法均通过修饰器实现,具体形式如下:
class MyClass:
def method(self):
print("method")
@staticmethod
def staticMethod():
print("static method")
@classmethod
def classMethod(cls):
print("class method")
python中静态方法与类方法均通过修饰器实现,具体形式如下:
class MyClass:
def method(self):
print("method")
@staticmethod
def staticMethod():
print("static method")
@classmethod
def classMethod(cls):
print("class method")