重慶分公司,新征程啟航
為企業(yè)提供網(wǎng)站建設(shè)、域名注冊(cè)、服務(wù)器等服務(wù)
為企業(yè)提供網(wǎng)站建設(shè)、域名注冊(cè)、服務(wù)器等服務(wù)
小編給大家分享一下python中l(wèi)og函數(shù)的使用方法,相信大部分人都還不怎么了解,因此分享這篇文章給大家參考一下,希望大家閱讀完這篇文章后大有收獲,下面讓我們一起去了解一下吧!
10年積累的網(wǎng)站設(shè)計(jì)、成都做網(wǎng)站經(jīng)驗(yàn),可以快速應(yīng)對(duì)客戶對(duì)網(wǎng)站的新想法和需求。提供各種問題對(duì)應(yīng)的解決方案。讓選擇我們的客戶得到更好、更有力的網(wǎng)絡(luò)服務(wù)。我雖然不認(rèn)識(shí)你,你也不認(rèn)識(shí)我。但先網(wǎng)站設(shè)計(jì)后付款的網(wǎng)站建設(shè)流程,更有立山免費(fèi)網(wǎng)站建設(shè)讓你可以放心的選擇與我們合作。
log() 返回 x 的自然對(duì)數(shù)。
語法
以下是 log() 方法的語法:
import math math.log(x[, base])
注意:log()是不能直接訪問的,需要導(dǎo)入 math 模塊,通過靜態(tài)對(duì)象調(diào)用該方法。
參數(shù)
x -- 數(shù)值表達(dá)式。
base -- 可選,底數(shù),默認(rèn)為 e。
返回值
返回 x 的自然對(duì)數(shù),x>0。
實(shí)例
以下展示了使用 log() 方法的實(shí)例:
#!/usr/bin/python # -*- coding: UTF-8 -*- import math # 導(dǎo)入 math 模塊 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) # 設(shè)置底數(shù) print "math.log(10,2) : ", math.log(10,2)
以上實(shí)例運(yù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 math.log(10,2) : 3.32192809489
以上是python中l(wèi)og函數(shù)的使用方法的所有內(nèi)容,感謝各位的閱讀!相信大家都有了一定的了解,希望分享的內(nèi)容對(duì)大家有所幫助,如果還想學(xué)習(xí)更多知識(shí),歡迎關(guān)注創(chuàng)新互聯(lián)行業(yè)資訊頻道!