Python 自定义一个正无穷大的整数
作者:互联网
1 作者:0x76 2 链接:https://www.zhihu.com/question/429361837/answer/1565316314 3 来源:知乎 5 6 class inf(int): 7 ''' 8 Infinite positive integer 9 ''' 10 def __init__(self): 11 pass 12 13 def __str__(self): 14 return 'inf_int' 15 16 def __float__(self) -> float: 17 return float('inf') 18 19 def __eq__(self, rhs) -> bool: 20 return False 21 def __ne__(self, rhs) -> bool: 22 return True 23 def __lt__(self, rhs) -> bool: 24 return False 25 def __le__(self, rhs) -> bool: 26 return False 27 def __gt__(self, rhs) -> bool: 28 return True 29 def __ge__(self, rhs) -> bool: 30 return True
标签:__,无穷大,return,自定义,Python,self,bool,rhs,def 来源: https://www.cnblogs.com/icxk/p/15739141.html