python @abstractmethod

1。寫在前面

因爲python 沒有抽象類、接口的概念,因此要實現這種功能得abc.py 這個類庫html

 

2。@abstractmethod特色

@abstractmethod:抽象方法,含abstractmethod方法的類不能實例化,繼承了含abstractmethod方法的子類必須複寫全部abstractmethod裝飾的方法,未被裝飾的能夠不重寫python

 

3。舉個反面栗子(實例化抽象類)

 

 4。舉個正常栗子

 

 

 

 參考htm

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

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

相關文章
相關標籤/搜索