How to keep a Python script output window open?

前端 未结 23 2911
挽巷
挽巷 2020-11-22 10:54

I have just started with Python. When I execute a python script file on Windows, the output window appears but instantaneously goes away. I need it to stay there so I can an

23条回答
  •  南旧
    南旧 (楼主)
    2020-11-22 11:06

    A very belated answer, but I created a Windows Batch file called pythonbat.bat containing the following:

    python.exe %1
    @echo off
    echo.
    pause
    

    and then specified pythonbat.bat as the default handler for .py files.

    Now, when I double-click a .py file in File Explorer, it opens a new console window, runs the Python script and then pauses (remains open), until I press any key...

    No changes required to any Python scripts.

    I can still open a console window and specify python myscript.py if I want to...

    (I just noticed @maurizio already posted this exact answer)

提交回复
热议问题