turtle 模块以面向对象和面向过程的方式提供 turtle 图形基元。由于它使用Tkinter作为基础图形,因此需要安装有Tk支持的Python版本。
turtle .left()
turtle.left()方法用于通过其参数值来更改 turtle 的方向。它使 turtle 的头部朝一个方向移动。
turtle.left(angle)
它接受的参数是angle {一个数字(整数或浮点数)}。因此,它以角度单位向左转 turtle 。 (单位默认为度,但可以通过degrees()和radians()功能进行设置。)角度方向取决于模式。
下面是上述方法的实现和一些示例:
范例1:
Python3
# importing package
import turtle
# move the turtle forward by
# 100 unit distance in the
# direction of head of turtle
turtle.forward(100)
# change the direction of turtle
# by 90 degrees to the left.
turtle.left(90)
# move the turtle forward by
# 100 unit distance in the
# direction of head of turtle
turtle.forward(100)
输出: