[Python] 纯文本查看 复制代码 class Flower:
name = 'flower'
picture = ''
def get_descript(self):
return self.name + self.picture
class Flower_test(Flower):
def get_descript(self):
a = 'test!'
a += super().get_descript()
return a
class Rose(Flower):
def get_descript(self):
return 'roseeeee!'
class Rosa(Flower):
def get_descript(self):
return 'rosaaaaa!'
class Student:
def __init__(self, flower):
self.flower = flower
if __name__ == '__main__':
for i in range(10):
if i < 3:
flower = Rose()
else:
flower = Rosa()
student = Student(flower)
print(student.flower.get_descript()) |