如何让python等待按下的键?
我希望脚本等待用户按下任何键。
我怎么做?
回答:
在Python 3中使用input():
input("Press Enter to continue...")在Python 2中使用raw_input():
raw_input("Press Enter to continue...")不过,这仅等待用户按下Enter键。
可能要使用msvcrt((仅适用于Windows / DOS)使用msvcrt模块可以访问Microsoft Visual C / C ++运行时库(MSVCRT)中的许多功能):
import msvcrt as mdef wait():
m.getch()
这应该等待按键。
附加信息:
Python 3 raw_input()中不存在
在Python 2 input(prompt)中等效于eval(raw_input(prompt))
以上是 如何让python等待按下的键? 的全部内容, 来源链接: utcz.com/qa/431856.html

