摘要: 比较两个类的两种方法:圆的面积 矩形和圆面积作比较 : 第一种: 通过装饰器来比较两个类:将共同代码抽出, 强制子类 实现area方法 import abcfrom functools import total_orderingimport math@total_orderingclass Shap 阅读全文
posted @ 2020-07-11 23:00 枫叶少年 阅读(161) 评论(0) 推荐(0) 编辑
摘要: 1. abc模块 ,不要以abc为模块名称 class Demo(object): def __init__(self, li): self.li = li def __len__(self): return len(self.li)l = ['c', '李云', '九折']d = Demo(l)p 阅读全文
posted @ 2020-07-11 15:14 枫叶少年 阅读(217) 评论(0) 推荐(0) 编辑