码迷,mamicode.com
首页 > 编程语言 > 详细

python 类的继承

时间:2020-07-13 21:25:58      阅读:78      评论:0      收藏:0      [点我收藏+]

标签:调用   ini   att   int   类的继承   ict   init   pytho   print   

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__)

 

python 类的继承

标签:调用   ini   att   int   类的继承   ict   init   pytho   print   

原文地址:https://www.cnblogs.com/zhaoxianxin/p/13295659.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!