python turtle教程1

时间:2026-02-20 11:48:58

1、首先我们import turtle,如果没报错就说明成功引用了turtle了。如果报错请在cmd命令行中输入pip install turtle。

python turtle教程1

2、 turtle.position()用来获取当前箭头的位置,一开始调用这个函数会初始化一个tk,位置为(0,0)

turtle.forward(x) 或者 turtle.fd(x) 沿着箭头方向前进x距离。

python turtle教程1

3、turtle.backward(x) 或者 turtle.bk(x) 沿着箭头反方向前进x距离。

python turtle教程1

4、turtle.heading()获取当前箭头温薪选材块的角度,一开始为0度。

turtle.right(x)或者 turtle.rt(x) 箭头方向向右旋转x度。

python turtle教程1

5、turtle.left(x)或者 turtle.lt(x) 箭祝阅头方向向左旋转x度。

python turtle教程1

6、turtle.setpos(x,y) 或者 turtle.goto(x,y) 或者 turtle.setposition(x,y)

直接去到某一个坐标(x,y)

python turtle教程1

7、turtle.setx(x)设置x坐标

turtle.sety(y)设置y坐标

python turtle教程1

python turtle教程1

8、turtle.setheading(x) 或者 turtle.seth(x) 设置角度x

python turtle教程1

9、turtle.home()返回原点,并且箭头方向为0度。

python turtle教程1

© 2026 五度知识库
信息来自网络 所有数据仅供参考
有疑问请联系站长 site.kefu@gmail.com