如何在python中更改此draw方法的起始位置?

问题描述 投票:0回答:2

此代码使用龟图形绘制几个字母:

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()

问题是它开始在屏幕中间绘制,我希望它从最左侧开始。有没有办法改变初始位置

python position draw turtle-graphics
2个回答
0
投票

使用turtle.penup拿起笔并移动到你想要的位置,然后做turtle.pendown


0
投票

请注意,乌龟界面是一个坐标网格。所以你可以使用goto(x, y)功能

turtle.penup()
turtle.goto(300,200)
turtle.pendown()
© www.soinside.com 2019 - 2024. All rights reserved.