Discuss / Python / 练习

练习

Topic source

AL

#1 Created at ... [Delete] [Delete and Lock User]
class Student(object):
    count = 0

    def __init__(self, name):
        self.name = name
        Student.count = Student.count+1

实例self 可以访问到Student类的属性,count。每创建一个实例,类属性count就加1


  • 1

Reply