Static method in class Python3, ordinary methods, class methods
Static methods : Method without self argument with @staticmethod decoration is called static methods, static methods of the class can no parameters, you can use the class name to call directly.
Common methods : the default parameters there is a self, and can only be called an object.
Class Methods : There cls default parameters, can be called classes and objects, we need to add @classmethod decorator.
. 1 class Classname: 2 @staticmethod . 3 DEF Fun (): . 4 Print ( ' static method ' ) . 5 . 6 @classmethod . 7 DEF A (CLS): . 8 Print ( " class method " ) . 9 10 # conventional method . 11 DEF B (Self ): 12 is Print ( ' conventional method ' ) 13 is 14 15 16 Classname.fun () . 17 Classname.a () 18 is 19 20 C = Classname() 21 C.fun() 22 C.a() 23 C.b()