摘要: 1.了解Python2和python3类的区别: python2.3之前使用的是经典类, 在2.3版本之后组,使用的是新式类 MRO: method resolution order 方法的查找顺序 MRO: method resolution order 方法的查找顺序 class Base: p 阅读全文
posted @ 2018-12-24 17:29 杨洪涛 阅读(112) 评论(0) 推荐(0) 编辑
摘要: 1.类的约束(重点): 写一个父类. 父类中的某个方法要抛出一个异常 NotImplementError # 项目经理 class Base: # 对子类进行了约束. 必须重写该方法 # 以后上班了. 拿到公司代码之后. 发现了notImplementedError 继承他 直接重写他 def lo 阅读全文
posted @ 2018-12-24 17:28 杨洪涛 阅读(191) 评论(0) 推荐(0) 编辑
摘要: 1.isinstance, type, issubclass 的含义 isinstance: 判断你给对象时候是xxx类型的.(向上判断) type: 返回xxx对象的数据类型 issubclass: 判断xxx类是否xxx的子类 class Animal: def eat(self): print 阅读全文
posted @ 2018-12-24 17:27 杨洪涛 阅读(175) 评论(0) 推荐(0) 编辑