'''self代表类的实例,而非类哪个对象调用方法,那么该方法中的self就代表那个对象self.__calss__ 代表类名'''class Person(object):def run(self):print("run")print(self.__class__)p = self.__class__("tt",30,10,20)print(p)def eat(self,food):print("eat"+food)def say(self):print("Hello!My name is %s,I am %d years old"%(self.name,self.age))#self不是关键字,换成其他的标识符也可以的但是帅的人都用selfdef play(a):print("wan "+a.name)def __init__(self,name,age,height,weight):# print(name,age,weight,height)# print("这里是init")self.name = nameself.height = heightself.age =ageself.weight = weightper1 = Person("hanmeimei ",21,160,80)
per1.say()per2= Person("tom ",22,160,80)
per2.say()per1.play()
per1.run()