class MyClass(object):
count = 0 #类成员
def __init__(self):
MyClass.count += 1
def getCount(self):
return MyClass.count #返回计数器
if __name__ == '__main__':
f = MyClass()
f1 = MyClass()
print(MyClass.count)
print(f1.getCount())