class lover:
lovernumber=0
def __init__(self,name,age,appearance):
self.name=name
self.age=age
self.appearance=appearance
print("Initial lover:{}".format(self.name))
lover.lovernumber+=1
@classmethod
def lover_how_many(cls):
print('lovers numbers are:',lover.lovernumber)
lover('A',20,90)
lover.lover_how_many()
lover('B',21,95)
lover.lover_how_many()
lover('C',22,99)
lover.lover_how_many()
print(type(lover))
输出:
Initial lover:A
lovers numbers are: 1
Initial lover:B
lovers numbers are: 2
Initial lover:C
lovers numbers are: 3
<class 'type'>
Process finished with exit code 0
手掌心
相关分类