Python Error :Inheriting 'X', which is not a class

Python Error :Inheriting 'X', which is not a class

我使用 Visual Studio 代码编写了代码

from datetime import date

Title = 'Actividad #$'
Complexity = 0
Time = 5 #cantidad en dias

class Activitie(Title,Complexity,Time):
    """Log your activity with this class"""

    Title = 'Actividad #$'
    Complexity = 0
    Time = 5 #cantidad en dias

它显示

Inheriting 'Time', which is not a class.
Inheriting 'Complexity', which is not a class.
Inheriting 'Title', which is not a class.

和...

TypeError: metaclass conflict: the metaclass of a derived class must be a (non-strict) subclass of the metaclasses of all its bases

感谢您提供任何解决方案

看起来您想定义 class 对象构造函数,但您不小心使用了 Python 的 class 继承语法。

下面是定义 class 及其对象构造函数的方法:

class Activitie:
    def __init__(self, Title, Complexity, Time):
    """Log your activity with this class"""

        self.Title = Title
        self.Complexity = Complexity
        self.Time = Time 

您收到此继承错误,因为在 Python 中声明继承的语法如下所示:

SubClass(ParentClassA, ParentClassB, ParentClassC):