这样有什么问题?
class Person(object):
__count = 0
def __init__(self, name):
self.name = name
Person.__count=Person.__count + 1
p1 = Person('Bob')
print Person.__count
p2 = Person('Alice')
print Person.__count
为什么同上一节一样的写代码,打印不出
1
2
class Person(object):
__count = 0
def __init__(self, name):
self.name = name
Person.__count=Person.__count + 1
p1 = Person('Bob')
print Person.__count
p2 = Person('Alice')
print Person.__count
为什么同上一节一样的写代码,打印不出
1
2
2017-06-14
举报