- 使用@staticmethod来声明静态函数
- 使用类名.方法名 来调用静态函数
- 使用类名.的方式来访问静态变量
class A:
ct = 0
def __init__(self,name):
self.name = name
self.ct =32
print 'parent init' , A.ct
A.ct+=1
def hello(self):
print self.name
class B(A):
def __init__(self):
A.__init__(self,'ss')
def jump(self):
print self.name ,',jumped'
@staticmethod
def jok():
print 'aa',B.ct
b = B()
c = B()
e = B()
d = B()
b.jump()
B.jok()