Python 类示例
来源:互联网 发布:企业移动办公软件 编辑:程序博客网 时间:2024/05/16 14:54
class Person: population = 0 def __init__(self , name): self.name = name print '(Initializing %s)' % self.name Person.population += 1 def __del__(self): print '%s says bye.' % self.name Person.population -= 1 if Person.population == 0: print 'I am the last one.' else: print 'There are still %d people left.' %Person.population def sayHi(self): print 'Hi ,my name is %s' % self.name def howMany(self): if Person.population == 1: print 'I am the only person here.' else: print 'We have %d person here.' % Person.populationhan = Person('han')han.sayHi()han.howMany()shuo = Person('shuo')shuo.sayHi() shuo.howMany()
0 0
- Python 类示例
- Python类的继承示例
- Python 类方法classmethod 示例
- Python示例
- python模拟登陆网站示例类
- python类成员变量引用示例
- Python学习笔记(13)-Python类与对象示例
- Python For Delphi 示例
- Python PAMIE示例
- python MySQLdb示例代码
- python 入门示例
- C++调Python示例
- python读excel示例
- python step1综合示例
- python 产生随机数示例
- Python 连接 Oracle 示例
- Python Socket多线程示例
- python thrift 示例
- C Primer Plus学习 五十五 数学库
- Java并发编程之十四:线程间通信中notify通知的遗漏(含代码)
- iOS中对图片的处理(对图片进行滤镜处理、调整图片饱和度、亮度、对比度、创建一张实时模糊效果 View (毛玻璃效果)、截取一张 view 生成图片)
- 从0开始学习 GitHub 系列之:向GitHub 提交代码
- hduoj 2143 box
- Python 类示例
- 重建二叉树
- Hibernate 关系映射 总结整理
- 实现JSP的继承(动态include)
- 城市的三级列表
- day01 Intent的使用
- Java并发编程之十五:线程间通信中notifyAll造成的早期通知问题(含代码)
- 欢迎使用CSDN-markdown编辑器
- 洛谷 P1038 神经网络