Commit ec55c037 by BellCodeEditor

auto save

parent d6c81a0f
Showing with 13 additions and 0 deletions
class Hero:#定义一个类 class 类名:
    def __init__(self,name,hp,attack):#多加几个形参
        self.level = 1#定义形参,定义成自己
        self.hp = hp
        self.attack = attack
yase = Hero("亚瑟",300,40)#name是"亚瑟",hp,attack是300,40
houyi = Hero("后羿",300,40)#按def __init__的方法里形参的顺序挨个写具体值(实参)
print(yase.hp)#打印yase的参数
print(yase.hp)#打印yase的参数
a = yase.hp+1
print(a)
def aio():
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