Python math.nan 常量

定义和用法

math.nan 常量返回浮点数的 nan(非数字)值。此值不是一个合法的数字。

nan 常量相当于 float("nan")

实例

打印 nan 的值:

# 导入 math 库
import math 

# 打印 nan 的值
print (math.nan)

亲自试一试

语法

math.nan

技术细节

返回值: 浮点数值,nan(非数字)。
Python 版本: 3.5