现在位置: 首页 > Python 3 教程 > 正文

Python math.degrees() 方法

Python math 模块 Python math 模块

Python math.degrees(x) 方法将角度 x 从弧度转换为度数。

PI (3.14..) 弧度等于 180 度,也就是说 1 弧度等于 57.2957795 度。

math.radians() 方法将度数值转换为弧度。

Python 版本: 2.3

语法

math.degrees() 方法语法如下:

math.degrees(x)

参数说明:

  • x -- 必需,数字。如果 x 不是一个数字,返回 TypeError。

返回值

返回一个浮点数,表示角度。

实例

以下实例返回不同弧度转换为度数:

实例

# 导入 math 包
import math

# 输出弧度转换为度数
print (math.degrees(8.90))
print (math.degrees(-20))
print (math.degrees(1))
print (math.degrees(90))

输出结果:

509.9324376664327
-1145.9155902616465
57.29577951308232
5156.620156177409

Python math 模块 Python math 模块