我有一个python类对象,我想分配一个类变量的值
class Groupclass(Workerclass):
"""worker class"""
count = 0
def __init__(self):
"""initialize time"""
Groupclass.count += 1
self.membercount = 0;
self.members = []
def __del__(self):
"""delte a worker data"""
Groupclass.count -= 1
if __name__ == "__main__":
group1 = Groupclass()
Run Code Online (Sandbox Code Playgroud)
此执行结果是正确的,但有一条错误消息说:
Exception AttributeError: "'NoneType' object has no attribute 'count'" in <bound method Groupclass.__del__ of <__main__.Groupclass instance at 0x00BA6710>> ignored
Run Code Online (Sandbox Code Playgroud)
谁能告诉我,我做错了什么?