描述
Python数法log()返回 x 的自然对数,因为 x > 0。
用法
以下是语法log()方法 -
import math
math.log( x )
注意− 此函数不可直接访问,因此需要导入 math 模块,然后使用 math 静态对象调用此函数。
参数
x- 这是一个数字表达式。
返回值
此方法返回 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
相关用法
- Python Number randrange()用法及代码示例
- Python Number choice()用法及代码示例
- Python Number sqrt()用法及代码示例
- Python Number acos()用法及代码示例
- Python Number floor()用法及代码示例
- Python Number asin()用法及代码示例
- Python Number round()用法及代码示例
- Python Number shuffle()用法及代码示例
- Python Number exp()用法及代码示例
- Python Number cmp()用法及代码示例
- Python Number max()用法及代码示例
- Python Number min()用法及代码示例
- Python Number sin()用法及代码示例
- Python Number pow()用法及代码示例
- Python Number uniform()用法及代码示例
- Python Number ceil()用法及代码示例
- Python Number cos()用法及代码示例
- Python Number abs()用法及代码示例
- Python Number degrees()用法及代码示例
- Python Number hypot()用法及代码示例
注:本文由纯净天空筛选整理自 Python Number log() Method。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。