python继承两个类
时间: 2023-06-09 08:01:54 浏览: 165
python类和继承用法实例
5星 · 资源好评率100%
您好!关于您的问题,可以用以下方式实现Python多继承:
class Class1:
def method1(self):
print("This is method 1 of Class1")
class Class2:
def method2(self):
print("This is method 2 of Class2")
class MyClass(Class1, Class2):
pass
my_object = MyClass()
my_object.method1() # 输出 This is method 1 of Class1
my_object.method2() # 输出 This is method 2 of Class2
希望能解决您的问题!
阅读全文