类的继承与继承的覆盖

类的继承与继承的覆盖
# 继承
class F:def __init__(self):self.info = "hello Father"def fun1(self):return self.infoclass S(F):passf = F()
s = S()print(f.fun1())  # hello Father
print(s.fun1())  # hello Father# 继承的覆盖
class F:def __init__(self):self.info = "hello Father"def fun1(self):return self.infoclass S(F):def __init__(self):self.info = "hello Son"def fun1(self):return self.infof = F()
s = S()print(f.fun1())  # hello Father
print(s.fun1())  # hello Son