Python/ref math log
来自菜鸟教程
<languages />
Python math.log()方法
例
查找不同数字的自然对数
# Import math Library
import math
# Return the natural logarithm
of different numbers
print(math.log(2.7183))
print(math.log(2))
print(math.log(1))
定义和用法
The
math.log()
方法返回数字的自然对数,或数字以对数为底的对数。
句法
math.log(x, base)
参数值
| 参数 | 描述 |
|---|---|
| x | 需要。指定要为其计算对数的值。如果值为0或负数,则返回ValueError。如果该值不是数字,则返回TypeError |
| base | 可选的。使用的对数底数。默认为“ e” |
技术细节
| 返回值: | A
|
| Python版本: | 在版本2.3中更改 |
| 变更记录: | The
base 参数已添加 |