- The Python Apprentice
- Robert Smallshire Austin Bingham
- 41字
- 2025-04-04 19:04:57
Special floating point values
By passing certain strings to the float constructor, we can create the special floating point value NaN (short for Not a Number) and also positive and negative infinity:
>>> float("nan")
nan
>>> float("inf")
inf
>>> float("-inf")
-inf