摘要: """开空间 调用__init__""" # class A:pass # class B(A):pass # print(B.__bases__) # 绑定方法和普通函数 from types import FunctionType, MethodType # FunctionType:函数 # 阅读全文
posted @ 2020-11-09 09:53 精灵中的二丫 阅读(53) 评论(0) 推荐(0) 编辑
摘要: class Animal: def __init__(self,name,food): self.name = name self.food = food self.blood = 100 self.waise = 100 def eat(self): # print('{} is eating { 阅读全文
posted @ 2020-11-09 09:52 精灵中的二丫 阅读(68) 评论(0) 推荐(0) 编辑
摘要: """组合:一个类对象是另一个类对象的属性""" # 学生类 ## 姓名 性别 年龄 学号 班级 手机号 #课程类 ## 班级名称 期数 讲师 class Student: def __init__(self,name,sex,age,stuid,stucls,phone): self.name = 阅读全文
posted @ 2020-11-09 09:51 精灵中的二丫 阅读(78) 评论(0) 推荐(0) 编辑
摘要: """面向对象的命名空间 实例找到类的方式: 实例中有类指针指向所在的类 """ class A: country = "中国" def __init__(self,name,age,country): self.name = name self.age = age # self.country = 阅读全文
posted @ 2020-11-09 09:48 精灵中的二丫 阅读(58) 评论(0) 推荐(0) 编辑
摘要: """object""" # class Person: # def __init__(self,name,age,sex): # #所有的在一个具体的人物出现之后拥有的属性 # print('-'*20) # self.name = name # self.age = age # self.sex 阅读全文
posted @ 2020-11-09 09:47 精灵中的二丫 阅读(60) 评论(0) 推荐(0) 编辑