📜  python代码示例中的属性

📅  最后修改于: 2022-03-11 14:47:09.281000             🧑  作者: Mango

代码示例1
class Monkey(object):
  def __init__(self, name): # This will done automatically when cmd in 7th line will be executed
    self.name = name # This is an attribute.
  def speak(self): # This is a method
    print("Hello! I am " + self.name)
    
IronMan = Monkey('TonyStark')
IronMan.speak() # This will use the function 'speak' defind in class 'Monkey'
# Created By ....