如何在 Python 中暂停和恢复 while 循环。你能帮我玩一下我用 python-turtle 构建的贪吃蛇游戏吗?
我使用 python 编程语言及其海龟库构建了一个蛇游戏。 在这里,您将找到我的代码的链接,我还在自述文件中提到了我需要的帮助,我将其保持得非常简短,以便您快速浏览。
I have built a snake game using python programming language and its turtle library.
Here you will find the link to my code, where I have also mentioned the help I need with it in Read Me file which I have kept really short and simple for you to go through it quickly.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在 Python 中,你无法真正暂停 while 循环并随意恢复它。但是,您可以做的是将 while 循环暂停几秒钟、几分钟或几小时。这可以使用时间库中的 .sleep() 方法来完成
例子:
In Python you can't really pause a while loop and resume it at your will. But, what you can do is pause the while loop for some seconds, minutes, or hours. This can be done using the .sleep() method from the time library
Example: