#Python其实有3个方法, the static method (Staticmethod), the class method (Classmethod), and the instance method, are as follows: Class Foo: def bar (self): # CLS is an instance of the current object Print ("bar") @staticmethod def STA (): print ("123") @staticmethod def stat (A1,A2): print ( A1,A2) @classmethod def classmd (CLS): #cls is the class name print (CLS) print ("Classmd") #静态方法执行, Static methods do not have to create Object Foo (). Bar () #需要创建对象调用Foo. STA () #直接用类调用Foo. Stat (in) #--------------------------------------print ( FOO.CLASSMD ()) #-------class method, saved in the class, called directly by the class, the CLS current Class-------------------------------# # #应用场景 "" If you need to save some values in the object, when you perform some kinetic energy You need to use the normal method in the object. Static methods are used when values in any object are not required. """
Methods in Python Use the