Commit 8e840ee1 by BellCodeEditor

save project

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