首页
学习
活动
专区
圈层
工具
发布
  • 您找到你想要的搜索结果了吗?
    是的
    没有找到

    【Python】面向对象 ④ ( 魔术方法 - 类内置方法 | `__str__` 字符串魔术方法 | 小于符号比较魔术方法 | 实现 `__lt__` 小于符号比较方法后也可以进行大于比较 )

    002_Project/011_Python/HelloPython/Hello.py Tom is 18 years old Process finished with exit code 0 三、小于符号比较方法...between instances of 'Student' and 'Student' 这是因为该类 , 没有实现 __lt__ 小于符号比较方法 ; 代码示例如下 : """ 面向对象 代码示例 "...supported between instances of 'Student' and 'Student' Process finished with exit code 1 2、实现 __lt__ 小于符号比较方法...在类中 , 实现 __lt__ 小于符号比较方法 , 下面实际比较的是 age 字段 ; def __lt__(self, other): return self.age <...D:/002_Project/011_Python/HelloPython/Hello.py False Process finished with exit code 0 3、实现 __lt__ 小于符号比较方法后也可以进行大于比较

    74810
    领券