博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
pyhon的语法缩进真叫一个蛋疼
阅读量:7119 次
发布时间:2019-06-28

本文共 1141 字,大约阅读时间需要 3 分钟。

hot3.png

class Person:    '''Represents a person.'''    population = 0    def __init__(self, name):        '''Initializes the person's data.'''        self.name = name        print '(Initializing %s)' % self.name        # When this person is created, he/she        # adds to the population        Person.population += 1    def __del__(self):        '''I am dying.'''        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):        '''Greeting by the person.        Really, that's all it does.'''        print 'Hi, my name is %s.' % self.name    def howMany(self):        '''Prints the current population.'''        if Person.population == 1:            print 'I am the only person here.'        else:            print 'We have %d persons here.' % Person.populationswaroop = Person('Swaroop')swaroop.sayHi()swaroop.howMany()kalam = Person('Abdul Kalam')kalam.sayHi()kalam.howMany()swaroop.sayHi()swaroop.howMany()

转载于:https://my.oschina.net/u/1455908/blog/370599

你可能感兴趣的文章
重写和重载
查看>>
本表收录的字符的Unicode编码范围为19968至40869
查看>>
PHP多次调用Mysql存储过程报错解决办法
查看>>
leetcode-680-Valid Palindrome II
查看>>
php用curl获取远端网页内容
查看>>
selenium+python谷歌驱动配置
查看>>
oralce的function处理考勤时间节点以及计算工作时间
查看>>
(三)、一步一步学GTK+之布局
查看>>
43. ExtJs控件属性配置详细
查看>>
ros名称、命名空间和重映射
查看>>
系统进程查看 --- 微软官方出品
查看>>
Python 第三方模块安装出现的问题和解决方案.
查看>>
实验1
查看>>
CF915E Physical Education Lessons(珂朵莉树)
查看>>
洛谷P5050 【模板】多项式多点求值
查看>>
第十章:基本数据结构(2)
查看>>
php处理管道文件流
查看>>
Centos 6 搭建安装 Gitlab
查看>>
2012.02.13(rtsp)
查看>>
关于设置安卓屏幕的显示方向
查看>>