Constante math.nan de Python

Python math 模块Module math de Python

Python math.nanRenvoie une valeur à virgule flottante nan (pas un nombre), qui n'est pas un nombre valide.

math.nanÉquivalent àfloat('nan')la sortie de

Syntaxe

La syntaxe de la constante math.nan est la suivante :

math.nan

Valeur de retour

Renvoie un nombre à virgule flottante nan.

Exemple

L'exemple suivant renvoie nan :

Exemple

# Importer le package math
import math

# Sortie nan
print (math.nan)

# Sortie nan type
print (type(math.nan))

Résultat de sortie :

nan
<class 'float'>

Python math 模块Module math de Python

Autres extensions