Commit c52a19c5 by BellCodeEditor

save project

parent 8f3c1e09
Showing with 7 additions and 17 deletions
class Hero:
def __init__(self,name,hp,attack):
self.level = 1
self.name = name
self.hp= hp
self.attack= attack
def upgrade(self):
self.level=self.level+1
self.hp=self.hp+50
self.attack=self.attack+4
houyi = Hero("后羿",240,23)
houyi.upgrade()
print("等级为:",houyi.level)
print("血量为: ",houyi.hp)
print("攻击力为:",houyi.attack)
file1 = open(r'C\Users\CM\Desktop\book.txt','w',encoding='utf-8')
file1.write('小兰:12本\n')
file1.write('小丽:11本\n')
file1.write('论文:9本\n')
file1.write('植物:16本\n')
file1.close()
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment