How to keep a Python script output window open?

前端 未结 23 2808
挽巷
挽巷 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:21

    In python 2 you can do it with: raw_input()

    >>print("Hello World!")    
    >>raw_input('Waiting a key...')
    

    In python 3 you can do it with: input()

    >>print("Hello world!")    
    >>input('Waiting a key...')
    

    Also, you can do it with the time.sleep(time)

    >>import time
    >>print("The program will close in 5 seconds")
    >>time.sleep(5)
    

提交回复
热议问题