Pause in Python

后端 未结 13 1241
臣服心动
臣服心动 2020-12-24 10:59

I am running command-line Python scripts from the Windows taskbar by having a shortcut pointing to the Python interpreter with the actual script as a parameter.

Afte

13条回答
  •  执笔经年
    2020-12-24 11:11

    In Windows, you can use the msvcrt module.

    msvcrt.kbhit() Return true if a keypress is waiting to be read.

    msvcrt.getch() Read a keypress and return the resulting character. Nothing is echoed to the console. This call will block if a keypress is not already available, but will not wait for Enter to be pressed.

    If you want it to also work on Unix-like systems you can try this solution using the termios and fcntl modules.

提交回复
热议问题