继承属性


"""
super()
"""


class Father:

def __init__(self):
self.name = '父亲'
self.age = 55
self.adress = '上海市'

def fangzi(self):
print('这是父亲的房子')

def chezi(self):
print('这是车子')


class Son(Father):

def __init__(self):
super().__init__()
self.name = '儿子'
self.age = 25


def chuangye(self):
print('创业。。。。。')

def fangzi(self):
super().fangzi()
print('这是儿子的房子')

s = Son()

print(s.name)
print(s.age)
print(s.adress)
print(s.fangzi())
posted @ 2023-07-18 23:56  echo1i  阅读(2)  评论(0编辑  收藏  举报