日韩无码专区无码一级三级片|91人人爱网站中日韩无码电影|厨房大战丰满熟妇|AV高清无码在线免费观看|另类AV日韩少妇熟女|中文日本大黄一级黄色片|色情在线视频免费|亚洲成人特黄a片|黄片wwwav色图欧美|欧亚乱色一区二区三区

RELATEED CONSULTING
相關(guān)咨詢
選擇下列產(chǎn)品馬上在線溝通
服務(wù)時(shí)間:8:30-17:00
你可能遇到了下面的問題
關(guān)閉右側(cè)工具欄

新聞中心

這里有您想知道的互聯(lián)網(wǎng)營銷解決方案
創(chuàng)新互聯(lián)Python教程:Pythonfloat()

float()方法從給定的數(shù)字或字符串中返回相應(yīng)的浮點(diǎn)數(shù)。

 **float([x])**#Where **x** can be a number or string that needs to convert 

浮點(diǎn)()參數(shù):

它接受需要返回浮點(diǎn)數(shù)的單個(gè)參數(shù)、數(shù)字或字符串

參數(shù) 描述 必需/可選
浮動(dòng)用作浮點(diǎn)數(shù)可選擇的
整數(shù)用作整數(shù)可選擇的
它包含十進(jìn)制數(shù)。前導(dǎo)空格和尾隨空格被刪除??蛇x使用“+”、“-”符號(hào)??梢园?NaN、Infinity、inf(小寫或大寫)。可選擇的

浮點(diǎn)()返回值

| 投入 | 返回值 | | 如果一個(gè)論點(diǎn) | 等效浮點(diǎn)數(shù) | | 如果沒有爭論 | 0.0  | | 該參數(shù)超出了 Python 浮點(diǎn)的范圍 | OverflowError 異常 |

Python 中float()方法的示例

示例 Python 中float()的工作原理?

 # for integers
print(float(20))

# for floats
print(float(12.33))

# for string floats
print(float("-15.34"))

# for string floats with whitespaces
print(float("     -32.25\n"))

# string float error
print(float("abcd")) 

輸出:

20.0
13.33
-15.34
-32.25
ValueError: could not convert string to float: 'abcd' 

例 2: float()表示無窮大,Nan(不是數(shù)字)?

 # for NaN
print(float("nan"))
print(float("NaN"))

# for inf/infinity
print(float("inf"))
print(float("InF"))
print(float("InFiNiTy"))
print(float("infinity")) 

輸出:

 nan
nan
inf
inf
inf
inf 

標(biāo)題名稱:創(chuàng)新互聯(lián)Python教程:Pythonfloat()
文章地址:http://m.5511xx.com/article/cohccpg.html