Python 实例方法、类方法、静态方法¶ 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15class A(object): # 实例方法,第一个参数 self 的值为当前的对象 def m1(self, n): print("self:", self) # 类方法,第一个参数 cls 的值为当前的类 @classmethod def m2(cls, n): print("cls:", cls) print(cls()) # 创建当前类的对象 # 静态方法,没有特殊的参数 @staticmethod def m3(n): pass