Python Pycharm 退出代码 0

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/20645129/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-18 20:55:39  来源:igfitidea点击:

Pycharm exit code 0

pythonpycharm

提问by goodcow

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

每当我运行任何代码时,我的控制台总是以Process finished with exit code 0.

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

例如,如果我只是打印(“hellow”):

pydev debugger: process 21021 is connecting

Connected to pydev debugger (build 131.618)
hellow

Process finished with exit code 0

Is there any way to make the output just "hellow"?

有没有办法让输出只是“你好”?

采纳答案by Paulo Bu

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 hellowas expected.

你意识到它不是输出的一部分吗?这只是 IDE 控制台提供的附加信息。真正的程序只是hellow按预期输出。

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

说这Process finished with exit code 0意味着一切正常。如果您的程序中发生异常或以其他方式使用exit非零参数生成异常,IDE 会通知您这一点,这是有用的调试信息。

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

在生产环境中,您不应该从 IDE 运行 Python 程序,因此我认为尝试删除它是无关紧要的。

回答by LGama

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