算术运算符重载 # 当对象出现在 '+' 的左边时会自动触发 def __add__(self, other): # 当对象出现在 '+' 的右边时会自动触发 def __radd__(self, other): # '+='运算时会自动触发,若没有实现则会尝试__add__ def __iadd__(self, other): 关系运算符重载 # 大于:> def __gt__(self, other): # 大于等于:>= def __ge__(self, other): # 小于:< def __lt__(self, other): # 小于等于:<= def __le__(self, other): # 等于:== def __eq__(self, other): # 不等于:!=,当没写时会尝试__eq__ def __ne__(self, other):
版权声明:除非特别标注,否则均为本站原创文章,转载时请以链接形式注明文章出处。
还木有评论哦,快来抢沙发吧~