随笔分类 - 设计-设计模式
摘要:非正式【鸭子类型】 # 接口 class InformalParserInterface: def load_data_source(self, path: str, file_name: str) -> str: """Load in the file for extracting text.""
阅读全文
摘要:https://francescocirillo.com/pages/anti-if-campaign # 编程时避免使用 if 语句的五种模式 https://www.techug.com/post/anti-if-the-missing-patterns.html # 设计模式消除大量if-el
阅读全文
摘要:python # python 天生支持多态 class Alipay(): def pay(self,money): print('已经用支付宝支付了%s元' % money) class Applepay(): def pay(self,money): print('已经用applepay支付了
阅读全文
摘要:https://www.cnblogs.com/Eva-J/articles/7293890.html java # java里的所有类的继承都是单继承,所以抽象类完美的解决了单继承需求中的规范问题 # 但对于多继承的需求,由于java本身语法的不支持,所以创建了接口Interface这个概念来解决
阅读全文
摘要:实验 # 可迭代对象就是你可以迭代的任何东西,而迭代器就是实际迭代的东西 my_iter = iter([1,2]) # 返回可迭代对象list的迭代器,就可以用next了 next(my_iter ) # 没有元素就会返回错误 # range不是迭代器的理由 # 1 不能调用next # 2 可以
阅读全文
浙公网安备 33010602011771号