在Python中,您可以执行以下操作:
test = float("inf")
在Python 3.5中,可以执行以下操作:
import math
test = math.inf
然后:
test > 1
test > 10000
test > x
永远都是真的.当然,除非如前所述,x也是无穷大或"nan"("不是数字").
此外(仅限Python 2.x),与Ellipsis
相比,float(inf)
更小,例如:
float('inf') < Ellipsis
结果会是真的.