Commit 8e840ee1 by BellCodeEditor

save project

parent 733c9dda
Showing with 9 additions and 7 deletions
class Hero: class Hero:
def __init__(self): def __init__(self,name,hp,attact):
self.hp = 300 self.name = name
self.hp = hp
self.level = 1 self.level = 1
self.attact = 20 self.attact = attact
#类方法的局部变量 #类方法的局部变量
color = 'red' # color = 'red'
#类方法的属性 局部变量不等于属性 #类方法的属性 局部变量不等于属性
self.color = color # self.color = color
yase = Hero() yase = Hero("后羿",300,100)
print(yase.hp) print(yase.hp)
\ 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