當前位置:成語大全網 - 新華字典 - python裏有內置的求對數的函數麽

python裏有內置的求對數的函數麽

在python中有內置的求對數的函數。

log()方法返回x的自然對數,對於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)

當我們運行上面的程序,它會產生以下結果:

math.log(100.12) : 4.60636946656

math.log(100.72) : 4.61234438974

math.log(119L) : 4.77912349311

math.log(math.pi) : 1.14472988585