以下是floor()方法的語法:
import math math.floor( x )
注意:此函數是無法直接訪問的,所以我們需要導入math模塊,然后需要用math的靜態對象來調用這個函數。
參數
返回值
此方法返回不大于x的最大整數。
例子
下面的例子顯示了floor()方法的使用。
#!/usr/bin/python import math # This will import math module print "math.floor(-45.17) : ", math.floor(-45.17) print "math.floor(100.12) : ", math.floor(100.12) print "math.floor(100.72) : ", math.floor(100.72) print "math.floor(119L) : ", math.floor(119L) print "math.floor(math.pi) : ", math.floor(math.pi)
當我們運行上面的程序,它會產生以下結果:
math.floor(-45.17) : -46.0 math.floor(100.12) : 100.0 math.floor(100.72) : 100.0 math.floor(119L) : 119.0 math.floor(math.pi) : 3.0
聲明:本網頁內容旨在傳播知識,若有侵權等問題請及時與本網聯系,我們將在第一時間刪除處理。TEL:177 7030 7066 E-MAIL:11247931@qq.com