在函数初始化地方 ,为什么要用person.count,而不直接用count
class Person(object):
count = 0
def __init__(self, name):
self.name = name
count = count + 1
p1 = Person('Bob')
print Person.count
p2 = Person('Alice')
print Person.count
p3 = Person('Tim')
print Person.count
class Person(object):
count = 0
def __init__(self, name):
self.name = name
count = count + 1
p1 = Person('Bob')
print Person.count
p2 = Person('Alice')
print Person.count
p3 = Person('Tim')
print Person.count
2015-09-24
举报