快捷导航

最后输出的问题

class Person(object):  __count = 0  def __init__(self, name):    self.name = name    Person.__count += 1    print Person.__countp1 = Person('Bob')p2 = Person('Alice')try:  print Person.__countexcept AttributeError:  print 'attributeerror'为什么最后会抛出attributeerror,求大神指点,谢谢

免责声明:本内容仅代表回答者见解不代表本站观点,请谨慎对待。

版权声明:作者保留权利,不代表本站立场。

回复

使用道具 举报

参与会员2

同意楼上观点,双下划线是私有属性,是不能在外部进行调用的。
回复

使用道具 举报

双下划线开头的属性是私有属性,是不能在外部访问的。。
回复

使用道具 举报

可能感兴趣的问答

发新帖
  • 微信访问
  • 手机APP