如何使用Python中的特定按钮的按下按下循环脱离循环?
我正在尝试构建一个简单的游戏,要求用户按“ P”开始,并开始生成不同的模式,直到用户按下“ S”。 Obviously what I have doesn't work, but I am not sure what to do at this point.
while ans == 'p' or ans == 'P':
function1()
function2()
function3()
if ans == 's' or ans == 'S':
break
我已经看到了使用键盘的解决方案。
谢谢!
I am trying to build a simple game where the user is asked to press 'P' to start, and it will start generating different patterns until the user presses 'S'. Obviously what I have doesn't work, but I am not sure what to do at this point.
while ans == 'p' or ans == 'P':
function1()
function2()
function3()
if ans == 's' or ans == 'S':
break
I have seen solutions where keyboard.is_pressed() is used but is there a way to do this without using any pre-defined function?
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论