Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我想知道一种简单的方法来等待用户按下特定键,如 Enter 或 Escape(但不是两者),然后在感应到按键后进一步执行代码。
尝试:
raw_input('Press enter to continue: ')
或者,在 Python 3 中:
input('Press enter to continue: ')
只需使用
raw_input('Press Enter')
这将打印消息,然后等待您按 Enter。