Python3 turtle 如何等待按键输入
我有一个用Python3的海龟模块写的简单游戏。当游戏结束时,我想显示一条消息“继续吗?(y/n)”,并等待用户按下键盘上的一个按钮。有没有什么好办法可以实现这个等待功能?
1 个回答
0
看看这个 textinput
方法:
def textinput(self, title, prompt):
"""Pop up a dialog window for input of a string.
Arguments: title is the title of the dialog window,
prompt is a text mostly describing what information to input.
Return the string input
If the dialog is canceled, return None.
Example (for a TurtleScreen instance named screen):
>>> screen.textinput("NIM", "Name of first player:")
"""
return simpledialog.askstring(title, prompt)