上一页 1 ··· 32 33 34 35 36 37 38 39 40 ··· 46 下一页
摘要: # 属性方法:把一个方法变成一个静态属性 #1 class Dog(object): def __init__(self,name): self.name=name @property#属性 def eat(self):#不能传参数(见调用时为d1.eat,不用加括号) print('%s is eating %s'%(self.name,... 阅读全文
posted @ 2018-03-02 22:19 耐烦不急 阅读(225) 评论(0) 推荐(0) 编辑
摘要: class Dog(object): def __init__(self,name): self.name=name @staticmethod#实际上跟类没什么关系了 def eat():#def eat(self)是错误的,self与上边没关系了 print('%s is eating %s'%('虎子','肉')) def t... 阅读全文
posted @ 2018-03-02 22:18 耐烦不急 阅读(149) 评论(0) 推荐(0) 编辑
摘要: 参考(都要认真看看):http://www.cnblogs.com/alex3714/articles/5188179.html 面向对象3大特性:封装,继承,多态 类: 属性:实例变量,类变量,私有属性__(两个下划线) 方法:构造方法,析构函数(不写的话,默认就有,相当于重构),私有方法 对象( 阅读全文
posted @ 2018-02-26 22:18 耐烦不急 阅读(270) 评论(0) 推荐(0) 编辑
摘要: #多态:一种接口,多种实现。主要作用:实现接口重用 #方法1: class Animal(object): def __init__(self,name): self.name=name class Cat(Animal): def talk(self): print('%s: 喵喵喵!' % self.name) class Dog(Animal... 阅读全文
posted @ 2018-02-26 12:04 耐烦不急 阅读(178) 评论(0) 推荐(0) 编辑
摘要: 参考:http://www.cnblogs.com/alex3714/articles/5188179.html 阅读全文
posted @ 2018-02-25 23:47 耐烦不急 阅读(224) 评论(0) 推荐(0) 编辑
摘要: 在python2中经典类是按照深度优先进行继承的,新式类是按照广度优先来进行继承的 在python3中经典类和新式类均是按照广度优先来继承的 参考:http://www.cnblogs.com/alex3714/articles/5188179.html 阅读全文
posted @ 2018-02-25 13:35 耐烦不急 阅读(272) 评论(0) 推荐(0) 编辑
摘要: 参考:http://www.cnblogs.com/alex3714/articles/5188179.html 阅读全文
posted @ 2018-02-25 12:36 耐烦不急 阅读(203) 评论(0) 推荐(0) 编辑
摘要: 参考:http://www.cnblogs.com/alex3714/articles/5188179.html #类变量的用途:大家共有的属性,节省内存 class Person(): cn='China' def __init__(self,name,age,addr,lifevalue=100 阅读全文
posted @ 2018-02-25 12:11 耐烦不急 阅读(449) 评论(0) 推荐(0) 编辑
摘要: 参考:http://www.cnblogs.com/alex3714/articles/5188179.html 阅读全文
posted @ 2018-02-25 11:10 耐烦不急 阅读(221) 评论(0) 推荐(0) 编辑
摘要: 参考:http://www.cnblogs.com/alex3714/articles/5188179.html 阅读全文
posted @ 2018-02-23 23:12 耐烦不急 阅读(149) 评论(0) 推荐(0) 编辑
上一页 1 ··· 32 33 34 35 36 37 38 39 40 ··· 46 下一页