针对turtle.setheading()与turtle.right(),turtle.left()的讨论:

针对turtle.setheading()与turtle.right(),turtle.left()的讨论:

以三角形为例:

  • turtle.left()
import turtle as t
for i in range(3):
    t.left(i*120)
    t.fd(200)

针对turtle.setheading()与turtle.right(),turtle.left()的讨论:_第1张图片

  • turtle.seth():
import turtle as t
for i in range(3):
    t.seth(i*120)	#海龟的方向始终是朝正方向
    t.fd(200)

针对turtle.setheading()与turtle.right(),turtle.left()的讨论:_第2张图片

  • 区别:
    <1>. turtle.left()与turtle.right()用法一致,所以我以turtle.left()为例,
    left为逆时针,right为顺时钟。
    小乌龟的方向随着旋转角度的变化而变化。
    <2>. turtle.setheading(angle)可简写为turtle.seth()
    其中逆时针旋转为正,顺时针旋转为负。
    小乌龟不管怎样旋转,它的方向始终是朝向x轴正方向

你可能感兴趣的:(python,python)