我只想打印出p1的结果,为什么p2能够自动运行输出?
#coding: utf-8 class Person(object): __count = 0 def __init__(self,name): Person.__count = Person.__count + 1 self.name = name print Person.__count p1 = Person('Bob') p2 = Person('Alice') try: print p1.__count except : print 'AttributeError'
输出依然是:
1
2
AttributeError