相关疑难解决方法(0)

__del__上的Python attributeError

我有一个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)

谁能告诉我,我做错了什么?

python class del attributeerror

11
推荐指数
1
解决办法
8189
查看次数

标签 统计

attributeerror ×1

class ×1

del ×1

python ×1