Python turtle.seth
时间: 2023-11-19 07:21:42 浏览: 176
python turtle库
5星 · 资源好评率100%
turtle.seth() is a method in the Python turtle module that sets the turtle's heading (direction) to a given angle in degrees. The angle argument can be any numeric value representing the desired angle in degrees. A positive angle value turns the turtle to the left, while a negative angle value turns it to the right.
Syntax:
turtle.seth(angle)
Example:
import turtle
t = turtle.Turtle()
t.seth(90) # set heading to 90 degrees (facing north)
t.forward(100) # move forward 100 units in the current direction
t.seth(-45) # set heading to -45 degrees (turning right)
t.forward(50) # move forward 50 units in the new direction
阅读全文