为什么Person.__count 不能写成self.__count
class Person(object):
__count = 0
@classmethod
def how_many(cls):
return cls.__count
def __init__(self,name):
self.name = name
self.__count = self.__count + 1
print Person.how_many()
p1 = Person('Bob')
print Person.how_many()
这样输出0 0