标记类方法@classmethod def get_count(cls):如何实现两次计算
class animal(object):
__count=0
def __init__(self,name,age):
self.name=name
self.age=age
animal.__count+=1
@classmethod
def get_count(cls):
return cls.__count
dog=animal('wangcai',2)
cat=animal('tom',3)
count=animal.get_count()
print(count)
#结果为2