你如何让 Python Turtle 停止移动? [英] How Do You Make Python Turtle Stop Moving?

查看:42
本文介绍了你如何让 Python Turtle 停止移动?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试过turtle.speed(0),我试过turtle.goto(turtle.xcor(), turtle.ycor()) 似乎没有任何效果.

I've tried to do turtle.speed(0), and I've tried turtle.goto(turtle.xcor(), turtle.ycor()) nothing is seeming to work.

这是代码:

import turtle

def stopMovingTurtle():
    ## Here I Need To Stop The Turtle ##

turtle.listen()
turtle.onkey(stopMovingTurtle, 'Return')
turtle.goto(-200, 0)
turtle.goto(200, 0)

那么我该如何阻止它?

推荐答案

只需在海龟代码"的末尾添加turtle.done().缩进与海龟命令相同.

Just add turtle.done() at the end of your "Turtle code". With the same indentation as the turtle commands.

这篇关于你如何让 Python Turtle 停止移动?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆