How to stop command prompt from closing in python?

前端 未结 3 936
时光说笑
时光说笑 2020-12-10 07:29

I am very new to python.. I used the code

x = input(\" Hey what is your name \" )       
print(\" Hey, \" + x)  
input(\" press close to exit \")
         


        
3条回答
  •  暖寄归人
    2020-12-10 07:58

    For Windows Environments:

    If you don't want to go to the command prompt (or work in an environment where command prompt is restricted), I think the following solution is gooThe solution I use is to create a bat file.

    Use notepad to create a text file. In the file the contents will look something like:

    my_python_program.py pause

    Then save the file as "my_python_program.bat" - DO NOT FORGET TO SELECT "All Files!

    When you run the bat file it will run the python program and pause at the end to allow you to read the output. Then if you press any key it will close the window.

提交回复
热议问题