我如何在python中有“按回车继续”功能?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/42077811/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-19 21:12:35  来源:igfitidea点击:

How do I have a "press enter to continue" feature in python?

python

提问by Pranav A.

I am writing a choose-your-own-adventure style game in python (terminal based) and I would like the program to pause printing until the enterbutton is pressed. Here is an example.

我正在用python(基于终端)编写一个选择你自己的冒险风格的游戏,我希望程序在enter按下按钮之前暂停打印。这是一个例子。

print("zzzzzzzzz")

the press enter to continue would come here. Then, after they press enter, this block would run.

按 Enter 继续会来到这里。然后,在他们按下 Enter 后,这个块就会运行。

print("yyyyyy")

Python 3 is preferable.

Python 3 是首选。

回答by Zdravko Danev

Python 2:

蟒蛇2:

raw_input("Press Enter to continue...")

Python 3:

蟒蛇3:

input("Press Enter to continue...")