You could add an option --pause
to your Python scripts, and prompt for keypress only if that option is set:
import getopt
import msvcrt
opts, args = getopt.getopt(sys.argv[1:], '...', ['pause', ...])
for opt, arg in opts:
if opt == "--pause":
promptForKeypress = True
...
...
if promptForKeypress:
msvcrt.getch() # note: Windows-only
# End of Script
That would require modifying all your scripts, though. Another option might be using a batch script like this for running your Python scripts:
@echo off
if not "%1"=="" (
python %*
pause
)
Use it like this:
pyrunner.cmd script.py {options}
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…