基本继承语法
class f1:
def f1(self):
print('f1')
class f2(f1):
def f2(self):
print('f2')
class f3(f2):
def f3(self):
print('f3')
obj = f3()
obj.f1()
obj.f2()
obj.f3()
class f1:
def f1(self):
print('f1')
class f2(f1):
def f2(self):
print('f2')
class f3(f1):
def f3(self):
print('f3')
obj = f3()
obj.f1()
obj.f3()
obj1 = f2()
obj1.f1()
obj1.f2()
多继承
class f1:
def f1(self):
print('f1')
class f2():
def f2(self):
print('f2')
class f3(f1,f2):
def f3(self):
print('f3')
obj = f3()
obj.f1()
obj.f2()
obj.f3()
网友评论