简体   繁体   English

Pycharm 退出代码 0

[英]Pycharm exit code 0

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"?有没有办法让输出只是“你好”?

You realize it is not part of the output right?你意识到它不是输出的一部分吗? It's just additional information provided by the IDE's console.这只是 IDE 控制台提供的附加信息。 The real program is just outputting hellow as expected.真正的程序只是按预期输出hellow

Saying that the Process finished with exit code 0 means that everything worked ok.Process finished with exit code 0意味着一切正常。 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.如果您的程序中发生异常或以其他方式生成带有非零参数的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 程序,因此我认为尝试删除它是无关紧要的。

I got the same error and reason in my case was that previous python script was running through Pycharm.我遇到了同样的错误,原因是以前的 python 脚本是通过 Pycharm 运行的。 To resolve this, trying stopping all previous running scripts from Pycharm then run your current script.要解决此问题,请尝试从 Pycharm 停止所有先前正在运行的脚本,然后运行您当前的脚本。 This may be helpful.这可能会有所帮助。

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM