Commit c42607dc by BellCodeEditor

auto save

parent f47689a4
Showing with 26 additions and 0 deletions
class Hero:
def __init__(self,name="亚瑟",hp=100,attact=50):
# def __init__(self,name,hp,attact):
self.level = 1
self.name = name
self.hp = hp
self.attact = attact
# # 类方法的局部变量
# color = "red"
# # 类方法的属性 局部变量不等于类属性
# self.color = color
def upgrade(self):
self.level = self.level+1
self.hp +=50
self.attact += 4
# yase = Hero("后羿",300,100)
yase = Hero("后羿",300,100)
hero_dict = yase.__dict__
# print(hero_dict["name"])
yase2 = Hero(hero_dict["name"],hero_dict["hp"],hero_dict["attact"])
print(yase2.name)
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