摘要: 当类中没有__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)