看这个代码,可以让你学得更多
class Person(object): count = 0 def __init__(self,name): self.name = name Person.count +=1 p1 = Person('Bob') p1.count = 100 print (p1.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 Person.count +=1 p1 = Person('Bob') p1.count = 100 print (p1.count) p2 = Person('Alice') print (Person.count) p3 = Person('Tim') print (Person.count)
2018-07-18
举报