How to keep a Python script output window open?

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

    `import sys,traceback
    sys.exc_info()[0]
    traceback.format_exc()
    print("Press Enter to exit ...")
    input()`
    

    simply write the above code after your actual code. for eg. am taking input from user and print on console hence my code will be look like this -->

    `import sys,traceback
    nam=input("enter your name:")
    print("your name is:-{}".format(nam)) #here all my actual working is done
    sys.exc_info()[0]
    traceback.format_exc()
    print("Press Enter to exit ...")
    input()`
    

提交回复
热议问题