python 类继承
来源:互联网 发布:前端php工程师招聘 编辑:程序博客网 时间:2024/06/08 05:47
class CAnimal: def __init__(self,param): print("CAnimal init method called.") self.name = param #property 定义一个属性name @property def name(self): return self.__name #为属性 name 定义修改器 @name.setter def name(self,name): self.__name = name def show(self): print(self.name,"is an animal") def __del__(self): print("CAnimal del method called")class CDog(CAnimal): def __init__(self,name,year): CAnimal.__init__(self,name) self.year = year print("CDog init method called") @property def year(self,data): self.__year= data def show(self): print(self.name,self.year,"is an dog") def __del__(self): print("CDog del method called.")dog =CDog("habagou",5)dog.show()
结果:
CAnimal init method called.
CDog init method called
('habagou', 5, 'is an dog')
CDog del method called.
0 0
- Python类的继承
- Python - 继承object类
- Python - 继承object类
- python类的继承
- Python 类的继承
- python 类继承
- Python类与继承
- Python 类的继承
- Python类的继承
- Python类继承
- Python类的继承
- Python进阶-类继承
- Python 6、类继承
- python ---类的继承
- Python类的继承
- Python:类的继承
- Python类和继承
- python 类的继承
- Windows Phone 8.1中应用数据之应用文件
- codeforces 380A A. Sereja and Prefixes(二分)
- was altered from
- TCP流重组的研究
- 关于工作与生活
- python 类继承
- Gradle第十二章:使用Gradle 图形用户界面
- Objective-C中的instancetype和id关键字
- 【按键】短按,长按,按键释放,三种模式的按键扫描程序(软件消抖动)
- 链接脚本在编程中的高级运用之一:可变长数组
- Android放大镜实现的两种方式
- Python装饰器学习
- jQuery性能优化
- Lee_JavaWeb学习之路_1(JSP基本语法)