Python math.degrees() 方法及代码示例
math.degrees(x):将角度 x 从弧度转换为度数
定义
math.degrees(x)
x为数值角度,将角度 x 从弧度转换为度数
参数
参数类型 | 参数名称 | 参数描述 |
---|---|---|
int,float | x | 数值x |
返回值
返回角度 x 从弧度转换为度数
示例
import math print("math.degrees(0) : ", math.degrees(0)) print("math.degrees(-math.pi / 2) : ", math.degrees(-math.pi / 2)) print("math.degrees(math.pi / 4) : ", math.degrees(math.pi / 4)) print("math.degrees(math.pi) : ", math.degrees(math.pi))
执行结果为 :
math.degrees(0) : 0.0 math.degrees(-math.pi / 2) : -90.0 math.degrees(math.pi / 4) : 45.0 math.degrees(math.pi) : 180.0