Python math.radians() 方法

约 437 字 更新于 2026-11-18 5iyo.com

Python math.radians() 方法

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

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

Python 版本: 2.0

语法

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

math.radians(x)

参数说明:

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

返回值

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

实例

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

实例

# 导入 math 包
import math

# 输出度数转换为弧度
print(math.radians(180))
print(math.radians(100.03))
print(math.radians(-20))

输出结果:


3.141592653589793

1.7458528507699278

-0.3490658503988659