此代码使用龟图形绘制几个字母:
import turtle
turtle.speed(1)
myWin = turtle.Screen()
turtle.left(90)
turtle.forward(260)
turtle.left(55)
turtle.forward(-60)
turtle.right(55)
turtle.forward(-60)
turtle.right(55)
turtle.forward(-60)
turtle.left(100)
turtle.forward(-60)
turtle.right(45)
turtle.forward(-60)
turtle.right(55)
turtle.forward(-50)
turtle.right(35)
turtle.forward(100)
turtle.left(90)
turtle.forward(260)
turtle.right(90)
turtle.forward(100)
turtle.right(90)
turtle.forward(100)
turtle.right(90)
turtle.forward(100)
turtle.right(50)
turtle.forward(-200)
turtle.right(130)
turtle.forward(50)
turtle.left(45)
turtle.forward(260)
myWin.exitonclick()
问题是它开始在屏幕中间绘制,我希望它从最左侧开始。有没有办法改变初始位置
使用turtle.penup
拿起笔并移动到你想要的位置,然后做turtle.pendown
请注意,乌龟界面是一个坐标网格。所以你可以使用goto(x, y)
功能
turtle.penup()
turtle.goto(300,200)
turtle.pendown()