新聞中心
python中用于計算對數(shù)的LOG()方法,是Python入門基礎(chǔ)中的必會的方法,需要的朋友可以參考下。

10年積累的成都網(wǎng)站建設(shè)、成都做網(wǎng)站經(jīng)驗,可以快速應(yīng)對客戶對網(wǎng)站的新想法和需求。提供各種問題對應(yīng)的解決方案。讓選擇我們的客戶得到更好、更有力的網(wǎng)絡(luò)服務(wù)。我雖然不認(rèn)識你,你也不認(rèn)識我。但先網(wǎng)站設(shè)計后付款的網(wǎng)站建設(shè)流程,更有禹城免費(fèi)網(wǎng)站建設(shè)讓你可以放心的選擇與我們合作。
log()方法返回x的自然對數(shù),x>0。
語法
以下是log()方法的語法:
import math math.log( x )
相關(guān)推薦:《Python教程》
注意:此函數(shù)是無法直接訪問的,所以我們需要導(dǎo)入math模塊,然后需要用math的靜態(tài)對象來調(diào)用這個函數(shù)。
參數(shù)
x -- 這是一個數(shù)值表達(dá)式。
返回值
此方法返回x的自然對數(shù),x>0。
例子
下面的例子顯示了log()方法的用法。
#!/usr/bin/python import math # This will import math module print "math.log(100.12) : ", math.log(100.12) print "math.log(100.72) : ", math.log(100.72) print "math.log(119L) : ", math.log(119L) print "math.log(math.pi) : ", math.log(math.pi)
當(dāng)我們運(yùn)行上面的程序,它會產(chǎn)生以下結(jié)果:
math.log(100.12) : 4.60636946656 math.log(100.72) : 4.61234438974 math.log(119L) : 4.77912349311 math.log(math.pi) : 1.14472988585
另外,可以通過log(x[, base])來設(shè)置底數(shù),如 log(x, 10) 表示以10為底的對數(shù)。
本文標(biāo)題:創(chuàng)新互聯(lián)Python教程:pythonlog運(yùn)算如何寫
轉(zhuǎn)載來源:http://m.fisionsoft.com.cn/article/coegjgs.html


咨詢
建站咨詢
