Pycharm exit code 0

后端 未结 2 877
长发绾君心
长发绾君心 2020-12-09 01:52

Whenever I run any code, my console always ends with Process finished with exit code 0.

For example, if i were to just print(\"hellow\"):



        
相关标签:
2条回答
  • 2020-12-09 02:11

    If you stop your script and it throws an exception you can add the following except that returns the same message.

    except KeyboardInterrupt:
        sys.exit(0)
    

    Returns

    Process finished with exit code 0
    
    0 讨论(0)
  • 2020-12-09 02:24

    You realize it is not part of the output right? It's just additional information provided by the IDE's console. The real program is just outputting hellow as expected.

    Saying that the Process finished with exit code 0 means that everything worked ok. If an exception occurs in your program or otherwise an exit is generated with non-zero argument, the IDE is gonna inform you about this, which is useful debug information.

    You're not supposed to run your Python programs from the IDE when in production so I think trying to remove that is irrelevant.

    0 讨论(0)
提交回复
热议问题