上一页 1 2 3 4 5 6 ··· 160 下一页
摘要: __add__(self, other): 用于 + 操作符__sub__(self, other): 用于 - 操作符__mul__(self, other): 用于 * 操作符__truediv__(self, other): 用于 / 操作符__floordiv__(self, other): 阅读全文
posted @ 2024-09-18 14:41 天子骄龙 阅读(4) 评论(0) 推荐(0) 编辑
摘要: 区别: +使用__add__函数,返回新地址 += 可变数据时使用__iadd__函数 ,返回原地址;不可变数据用__add__函数 不可变数据 #不可变数据 +和+= 都用__add__函数 i=10 i=i+2 print(id(i)) i+=2 print(id(i)) 可变数据 # 可变数据 阅读全文
posted @ 2024-09-17 11:09 天子骄龙 阅读(3) 评论(0) 推荐(0) 编辑
摘要: 当类中没有__eq__函数时,根据地址比较 class Vector: def __init__(self, x, y): self.x = x self.y = y pos1=Vector(1,1) pos2=Vector(1,1) print(pos2==pos1) 自定义Vector类中没有_ 阅读全文
posted @ 2024-09-16 06:50 天子骄龙 阅读(4) 评论(0) 推荐(0) 编辑
摘要: 单继承 在单继承中super主要是用来调用父类的方法的 class A: def __init__(self): self.n = 2 def add(self, m): print('self is {0} @A.add'.format(self)) self.n += m class B(A): 阅读全文
posted @ 2024-09-16 06:02 天子骄龙 阅读(3) 评论(0) 推荐(0) 编辑
摘要: aa 阅读全文
posted @ 2024-09-15 19:58 天子骄龙 阅读(8) 评论(0) 推荐(0) 编辑
摘要: 客厅柜机遥控器 主卧空调遥控器 aa 阅读全文
posted @ 2024-09-14 17:22 天子骄龙 阅读(7) 评论(0) 推荐(0) 编辑
摘要: aa 阅读全文
posted @ 2024-09-11 10:19 天子骄龙 阅读(4) 评论(0) 推荐(0) 编辑
摘要: __dict__是用来存储对象属性的一个字典,其键为属性名,值为属性的值 class people: def __init__(self, id=0,name="",age=0): #初始化函数 #id是创建对象时要输入的参数 self.id = id #self.id 是对象属性 self.nam 阅读全文
posted @ 2024-09-03 10:56 天子骄龙 阅读(2) 评论(0) 推荐(0) 编辑
该文被密码保护。 阅读全文
posted @ 2024-09-02 09:11 天子骄龙 阅读(0) 评论(0) 推荐(0) 编辑
摘要: Mini USB公 Micro USB母 阅读全文
posted @ 2024-09-02 08:36 天子骄龙 阅读(4) 评论(0) 推荐(0) 编辑
上一页 1 2 3 4 5 6 ··· 160 下一页