Python3 math.inf常量 - 無窮大常量

2023-04-23 17:57 更新

Python math 模塊  math 模塊


描述

Python ?math.inf ?正無窮大的浮點數(shù),負無窮大,使用? -math.inf? 。

?math.inf ?相當于? float('inf')? 的輸出。


語法

?math.inf? 常量語法如下:

math.inf

返回值

返回一個浮點數(shù),表示正無窮大。


實例

以下實例返回正無窮大與負無窮大:

# 導入 math 包
import math

# 輸出正無窮大
print (math.inf)

# 輸出負無窮大
print (-math.inf)

輸出結(jié)果:

inf
-inf

Python math 模塊  math 模塊


以上內(nèi)容是否對您有幫助:
在線筆記
App下載
App下載

掃描二維碼

下載編程獅App

公眾號
微信公眾號

編程獅公眾號