[英]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 object 构造函数,但您不小心使用 Python 的 class Z5FED3411FAF8321C4B666Z 语法完成了它。
以下是定义 class 及其 object 构造函数的方法:
class Activitie:
def __init__(self, Title, Complexity, Time):
"""Log your activity with this class"""
self.Title = Title
self.Complexity = Complexity
self.Time = Time
您收到此 Inheritance 错误,因为在 Python 中声明 inheritance 的语法如下所示:
SubClass(ParentClassA, ParentClassB, ParentClassC):
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.