1。写在前面

由于python 没有抽象类、接口的概念,所以要实现这种功能得abc.py 这个类库

 

2。@abstractmethod特点

@abstractmethod:抽象方法,含abstractmethod方法的类不能实例化,继承了含abstractmethod方法的子类必须复写所有abstractmethod装饰的方法,未被装饰的可以不重写

 

3。举个反面栗子(实例化抽象类)

python  @abstractmethod

 

 4。举个正常栗子python  @abstractmethod

 

 

 

 参考

http://www.cnblogs.com/bjdxy/archive/2012/11/15/2772119.html

https://www.jianshu.com/p/a340ffb231a0

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-11-21
  • 2022-01-07
  • 2021-12-15
  • 2021-06-12
  • 2021-09-19
猜你喜欢
  • 2022-12-23
  • 2021-07-30
  • 2021-10-07
  • 2021-07-04
  • 2021-07-23
  • 2021-06-15
  • 2022-12-23
相关资源
相似解决方案