为什么创建第二个实例之后打印不出来1
class Person(object):
__count = 0
@classmethod
def how_many(cls):
return cls.__count
def __init(self, name):
self.name = name
Person.__count += 1
print Person.how_many()
p1 = Person('Bob')
print Person.how_many()
class Person(object):
__count = 0
@classmethod
def how_many(cls):
return cls.__count
def __init(self, name):
self.name = name
Person.__count += 1
print Person.how_many()
p1 = Person('Bob')
print Person.how_many()
2016-07-30
举报