codecamp

Python3 math.nan常量 - 非法数字

Python math 模块 math 模块


描述

Python math.nan 返回一个浮点值 nan(not a number,不是一个数字),这个值不是一个合法数字。

math.nan 相当于 float('nan') 的输出。


语法

math.nan 常量语法如下:

math.nan

返回值

返回一个浮点数 nan。


实例

以下实例返回 nan:

# 导入 math 包
import math

# 输出 nan
print (math.nan)

# 输出 nan 类型
print (type(math.nan))

输出结果:

nan
<class 'float'>

Python math 模块 math 模块


Python3 math.inf常量 - 无穷大常量
Python3 math.pi常量 - 圆周率π
温馨提示
下载编程狮App,免费阅读超1000+编程语言教程
取消
确定
目录

相关教程

Python基础教程

python内置库

python3 math模块

关闭

MIP.setData({ 'pageTheme' : getCookie('pageTheme') || {'day':true, 'night':false}, 'pageFontSize' : getCookie('pageFontSize') || 20 }); MIP.watch('pageTheme', function(newValue){ setCookie('pageTheme', JSON.stringify(newValue)) }); MIP.watch('pageFontSize', function(newValue){ setCookie('pageFontSize', newValue) }); function setCookie(name, value){ var days = 1; var exp = new Date(); exp.setTime(exp.getTime() + days*24*60*60*1000); document.cookie = name + '=' + value + ';expires=' + exp.toUTCString(); } function getCookie(name){ var reg = new RegExp('(^| )' + name + '=([^;]*)(;|$)'); return document.cookie.match(reg) ? JSON.parse(document.cookie.match(reg)[2]) : null; }