class hero():
def __init__(self,name,level,hp,attack): self.level=level self.hp=hp self.attack=attack
def upgrade(): yase.level=yase.level+2 yase.hp=yase.hp+50 yase.attack=yase.attack+5
yase=hero('亚瑟',5,500,2) print('亚瑟的攻击',yase.attack)
upgrade() upgrade() print('升级2次后,输出亚瑟的血量:',yase.hp)