python 子類重寫父類的方法

子類拓展了父類,子類是一種特殊的父類,大部分時候,子類老是以父類爲基礎,額外增長新的方法,但有一種狀況例外,子類須要重寫父類的方法,見代碼:python class Animal: def eat(self): print('kkkkkk') class Person(Animal): def eat(self): print('hhhhhhhh'
相關文章
相關標籤/搜索