Only operation class properties, no instance object properties, no self method functions. @ Staticmethod must be written above. If @ staticmethod is not written, the method is considered as an instance method and the first parameter must be self. Static methods can be triggered by class calls or instance calls. It can be inherited, And the subclass or subclass instance object can still be called.
_________________________________________________________________
Class aa:
X = 100
Def _ init _ (self ):
Self. x = 10
Self. y = 12
Def hello (self, x ):
Return x + 1
@ Staticmethod
Def pr ():
Print 'aa class x', aa. x
Class bb (aa ):
Def _ init _ (self ):
Aa. _ init _ (self)
Self. z = 14
A = aa ()
Print a. x, a. y
A. pr ()
Aa. pr ()
B = bb ()
Print B. x, B. y
_________________________________________________________________
The running result is as follows:
10 12
Aa class x 100
Aa class x 100
10 12
Aa class x 100
Aa class x 100
_________________________________________________________________