Python @classmethod中的C.x和cls.x有什么区别?
以下代码:Python @classmethod中的C.x和cls.x有什么区别?,python,python-3.x,static-methods,class-method,Python,Python 3.x,Static Methods,Class Method,以下代码: class C: x = 0 @classmethod def increment1(cls): cls.x += 1 @classmethod def increment2(cls): C.x += 1 @staticmethod def increment3(): C.x += 1 方法increment1、increment2和increment3之间是否有任何区别
class C:
x = 0
@classmethod
def increment1(cls):
cls.x += 1
@classmethod
def increment2(cls):
C.x += 1
@staticmethod
def increment3():
C.x += 1
方法
increment1
、increment2
和increment3
之间是否有任何区别?考虑一下如果将C.DanielRoseman Thx子类作为提示,会发生什么。这是唯一的区别吗?所以,increment2
和increment3
之间没有区别?