python __def__ Exception AttributeError: "'NoneType' object has no attribute

来源:互联网 发布:域名如何跟服务器绑定 编辑:程序博客网 时间:2024/05/27 02:33
 14         def __del__(self): 15                 '''delete a person.''' 16                 print 'delete person %s' % self.name 17                 self.__class__.population -= 1 18                 if self.__class__.population == 0: 19                         print 'there is no one in here' 20                 else: 21                         print 'there are %d in here' % self.__class__.popula    tion

开始的时候我是用的Object.population。所以,出现了上面的错误。后来网上查了下资料,要将其改为:

self.__class__.population才行。 

原创粉丝点击