Discuss / Python / 类属性和实例属性

类属性和实例属性

Topic source
class Student(object):    count = 0    # 实例化对象时,自动调用init方法,类属性+1    def __int__(self,name):        self.name = name        Student.count += 1

  • 1

Reply