python基础-类成员变量-提供python2代码,可以直接测试,部分代码如下
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
, 相关下载链接:
https://download.csdn.net/download/li171049/88054304?utm_source=bbsseo