编写一个学生类,产生一堆学生对象 要求:有一个计数器(属性),统计总共实例了多少个对象
class Student():
count = 0
def init(self,name):
self.name = name
Student.count += 1
a = Student(‘A’)
b = Student(‘B’)
c = Student(‘C’)
e = Student(‘D’)
print (Student.count)
编写一个学生类,产生一堆学生对象 要求:有一个计数器(属性),统计总共实例了多少个对象
class Student():
count = 0
def init(self,name):
self.name = name
Student.count += 1
a = Student(‘A’)
b = Student(‘B’)
c = Student(‘C’)
e = Student(‘D’)
print (Student.count)