degrees() 函數可以將弧度轉換為角度。
語法
以下是 degrees() 方法的語法:
import?math math.degrees(x)
注意:degrees() 是不能直接訪問的,需要導入 math 模塊,然后通過 math 靜態對象調用該方法。
參數
x -- 一個數值。
返回值
返回一個角度值。
實例
以下展示了使用 degrees() 方法的實例:
#!/usr/bin/python import?math print?"degrees(3)?:?",??math.degrees(3) print?"degrees(-3)?:?",??math.degrees(-3) print?"degrees(0)?:?",??math.degrees(0) print?"degrees(math.pi)?:?",??math.degrees(math.pi) print?"degrees(math.pi/2)?:?",??math.degrees(math.pi/2) print?"degrees(math.pi/4)?:?",??math.degrees(math.pi/4)
以上實例運行后輸出結果為:
degrees(3)?:??171.887338539 degrees(-3)?:??-171.887338539 degrees(0)?:??0.0 degrees(math.pi)?:??180.0 degrees(math.pi/2)?:??90.0 degrees(math.pi/4)?:??45.0