class Person(object): count = 0 @classmethod def show_people_count(cls): print('显示创建的人数:%s' % cls.count) def __init__(self, name): self.name = name Person.count += 1 P1 = Person('yeyu') Person.show_people_count()