Python3龟怎么等到按键

时间:2013-03-19 09:08:32

标签: python-3.x turtle-graphics

我有一个用Python3龟编写的简单游戏 游戏结束后我想显示消息'继续? (y / n)'并等到用户按下键盘上的按钮。任何想法如何实现等待功能?

1 个答案:

答案 0 :(得分: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)