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__)
邮箱: 1090055252@qq.com