Commit e9f2ebc9 by BellCodeEditor

save project

parent b4383165
Showing with 6 additions and 6 deletions
class Hero: class Hero:
def __init__(self,name,dps,hp): def __init__(self,name,dps,hp):#def后空格很重要!!!!! __init__要有两个下划线!!!!!
self.level=1 self.level=1
self.name=name self.name=name
self.dps=dps self.dps=dps
self.hp=hp self.hp=hp
ys=Hero('ys',1,1) h1=Hero('鸭瑟',1,1)
hy=Hero('hy',2,2) h2=Hero('鸭瑟',2,2)
print('ys血量:',ys.hp) print('鸭瑟血量:',h1.hp)
print('hy血量:',hy.hp) print('鸭瑟血量:',h2.hp)
\ No newline at end of file \ 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