30秒学会 Python 片段 – rads_to_degrees
Converts an angle from radians to degrees.
Use math.pi
and the radian to degree formula to convert the angle from radians to degrees.
代码实现
from math import pi
def rads_to_degrees(rad):
return (rad * 180.0) / math.pi
使用样例
from math import pi
rads_to_degrees(math.pi / 2) # 90.0