Python math.log2() 方法
例如:
查找不同数字的以2为底的对数
# Import math Library import math # Return the base-2 logarithm of different numbers print(math.log2(2.7183)) print(math.log2(2)) print(math.log2(1))
1、定义和用法
math.log2()方法返回数字的以2为底的对数。
2、调用语法
math.log2(x)
3、参数说明
参数  | 描述  | 
x  | 必需的参数, 指定要为其计算对数的值。 如果值为0或负数,则返回ValueError。 如果该值不是数字,则返回TypeError  | 
4、方法说明
返回值:  | 
  | 
Python Version:  | 3.3  |