python 类的继承

class Person():
    def __init__(self, name):
        self.name = name

    def setName(self, name):
        self.name = name

class Satter(Person):
    def __init__(self, name, company):
    # 调用父类方法 super(Satter, self).
__init__(name) self.company = company def setCompany(self, company): self.company = company if __name__ == "__main__": s = Satter("zhao", "byte") print(s.__dict__) s.setName("hahah") print(s.__dict__)

 

posted @ 2020-07-13 20:59  Black_Climber  阅读(129)  评论(0编辑  收藏  举报