Python中的 turtle.degrees()函数
turtle 模块以面向对象和面向过程的方式提供海龟图形原语。因为它使用 tkinter 作为底层图形,所以它需要安装一个支持 Tk 的Python版本。
海龟.度()
此方法用于将角度测量单位设置为度。默认情况下,角度测量单位是“度”。
Syntax: turtle.degrees(fullcircle=360.0)
Parameter:
fullcircle(optional): a number. Set angle measurement units, i.e. set number of ‘degrees’ for a full circle. Default value is 360 degrees.
下面是上述方法的一个例子的实现:
Python3
# importing package
import turtle
# set turtle speed
turtle.speed(1)
# forward turtle by 100
turtle.forward(100)
# turn the turtle (degrees)
turtle.left(90)
# print heading
print(turtle.heading())
# move forward by 100
turtle.forward(100)
# set to radians
turtle.radians()
# turn to left by 90 (radians)
turtle.left(1.57079633)
# print heading
print(turtle.heading())
# move forward by 100
turtle.forward(100)
# set to radians
turtle.degrees()
# turn to left by 90 (degrees)
turtle.left(90)
# print heading
print(turtle.heading())
输出 :