class Hero: def __init__(self,name,hp,attack): self.level = 1 self.name = name self.hp = hp self.attack = attack def upgrade(self): yase.hp = yase.hp+100 yase.level = yase.level+1 yase.attack = yase.attack+50 libai = Hero("李白",200,30) yase = Hero("亚瑟",250,20) yase.upgrade() libai.upgrade() print(libai.hp) # print(yase.hp)