摘要: # 继承(单继承、多继承) # 父亲,母亲,儿子,女儿,父亲会说话,母亲会写字,儿子继承了父亲,女儿继承了父母,并且有新能力说, # 小儿子继承父亲,但优化了能力,三儿子继承父亲的能力,但需要扩展 # 父亲类(基类) class father(): def spaek(self): print("I can speak 1") # 单继承:class 子类(父类) cl... 阅读全文
posted @ 2019-07-24 14:34 Peach~ 阅读(563) 评论(0) 推荐(0) 编辑
摘要: # 类和对象 ''' 创建一个类 class 类名: 类里面的内容 ''' class cl1(): pass ''' 实例化一个类 a = cl1() ''' # 构造函数 # self:在类中的方法必须加上self # __init__(self,参数) # 构造函数实际意义:初始化 class cl2: def __init__(self): pr... 阅读全文
posted @ 2019-07-24 14:33 Peach~ 阅读(183) 评论(0) 推荐(0) 编辑