摘要: class Person(object): def run(self): print(self.__money) print("run") def eat(self, food): print("eat " + food) def __init__(self, name, age, height, 阅读全文
posted @ 2020-02-10 21:22 i勤能补拙 阅读(236) 评论(0) 推荐(0) 编辑
摘要: '''重写:将函数重写定义写一遍__str__():在调用print打印对象时自动调用,是给用户用的,是一个描述对象的方法。__repr__():是给机器用的,在Python解释器里面直接敲对象名在回车后调用的方法注意:在没有str时,且有repr,str = repr'''class Person 阅读全文
posted @ 2020-02-10 20:53 i勤能补拙 阅读(844) 评论(0) 推荐(0) 编辑
摘要: '''析构函数:__del__() 释放对象是自动调用'''class Person(object): def run(self): print("run") def eat(self, food): print("eat " + food) def __init__(self, name, age 阅读全文
posted @ 2020-02-10 20:27 i勤能补拙 阅读(711) 评论(0) 推荐(0) 编辑
摘要: '''self代表类的实例,而非类哪个对象调用方法,那么该方法中的self就代表那个对象self.__class__ 代表类名_'''class Person(object): def run(self): print("run") print(self.__class__) p = self.__ 阅读全文
posted @ 2020-02-10 17:02 i勤能补拙 阅读(2288) 评论(0) 推荐(0) 编辑
摘要: class Person(object): #name = "stu" #age = 10 #height = 160 #weight = 90 def run(self): print("run") def eat(self, food): print("eat " + food) def __i 阅读全文
posted @ 2020-02-10 11:17 i勤能补拙 阅读(1445) 评论(0) 推荐(0) 编辑
摘要: class Person(object): name = "stu" age = 10 height = 160 weight = 90 def run(self): print("run") def eat(self, food): print("eat " + food) def openDoo 阅读全文
posted @ 2020-02-10 11:14 i勤能补拙 阅读(2119) 评论(0) 推荐(0) 编辑