python编程小提示
16lz
2021-01-22
一.面向对象的约束
1.基于人为的约束
calss BaseMessage(object): def send(self,x): #必须继承BaseMessage,然后其中必须编写send方法.用于具体业务逻辑. raise NotImplementedError(".send() 必须被重写") class Email(BaseMessage): def send(self,x): #必须继承BaseMessage,然后其中必须编写send方法,用于完成具体逻辑 return x obj = Email() obj,send(1)
更多相关文章
- Python安装模块(numpy等)问题的两种解决办法——常规方法和Anacond
- python魔法方法、构造函数、序列与映射、迭代器、生成器
- Python 字典 pop() 方法
- 对照java和spring理解python中单例模式的装饰器方法
- Python下numpy不成功的解决办法(wheel方法安装,试用其他包)
- 关于python中的类方法(classmethod)和静态方法(staticmethod)
- python中的类与方法
- 如何为Google Cloud Endpoints方法生成pydoc文档?
- python笔记7:接口实现方法