上一页 1 2 3 4 5 6 7 8 9 10 ··· 164 下一页
摘要: __eq__(self, other):用于 == 操作符__ne__(self, other):用于 != 操作符__lt__(self, other):用于 < 操作符__le__(self, other):用于 <= 操作符__gt__(self, other):用于 > 操作符__ge__( 阅读全文
posted @ 2024-09-18 14:47 天子骄龙 阅读(26) 评论(0) 推荐(0)
摘要: __add__(self, other): 用于 + 操作符__sub__(self, other): 用于 - 操作符__mul__(self, other): 用于 * 操作符__truediv__(self, other): 用于 / 操作符__floordiv__(self, other): 阅读全文
posted @ 2024-09-18 14:41 天子骄龙 阅读(29) 评论(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 天子骄龙 阅读(69) 评论(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 天子骄龙 阅读(69) 评论(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 天子骄龙 阅读(33) 评论(0) 推荐(0)
摘要: aa 阅读全文
posted @ 2024-09-15 19:58 天子骄龙 阅读(20) 评论(0) 推荐(0)
摘要: 客厅柜机遥控器 主卧空调遥控器 aa 阅读全文
posted @ 2024-09-14 17:22 天子骄龙 阅读(2583) 评论(0) 推荐(0)
摘要: aa 阅读全文
posted @ 2024-09-11 10:19 天子骄龙 阅读(92) 评论(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 天子骄龙 阅读(26) 评论(0) 推荐(0)
摘要: 上网账号 下载app aa 阅读全文
posted @ 2024-09-02 09:11 天子骄龙 阅读(13) 评论(0) 推荐(0)
上一页 1 2 3 4 5 6 7 8 9 10 ··· 164 下一页