立即学习:https://edu.csdn.net/course/play/26676/339580?utm_source=blogtoedu
class Foo:
def method(self,x):##self表示当前实例,这是实例方法
retrun x*2
class Bar:
@classmethod
def method(cls,x): ##cls表示当前类,这是类方法
print(cls)
类方法可用于定义实例
class Bar2:
@staticmethod:
def add(): ##静态方法不与实例绑定,这是静态方法
return 'add'