Python “进程已完成,退出代码为 1”是什么意思?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/47970844/
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-19 18:27:35  来源:igfitidea点击:

what is "Process finished with exit code 1" mean?

pythonpython-3.xpyqt5qt-designer

提问by bsekili

I am beginner in Python. I tried to develop simple currency program but i have problem. can someone helps me ? When i click "?evir" , program should calculate money(like exchange). But i cant do it. PyCharm write "Process finished with exit code 1" when i click "?evir"

我是 Python 初学者。我试图开发简单的货币程序,但我有问题。有人可以帮助我吗?当我点击“?evir”时,程序应该计算钱(如交换)。但我做不到。当我点击“?evir”时,PyCharm 写“进程完成,退出代码 1”

from PyQt5 import QtCore, QtGui, QtWidgets
from PyQt5.QtGui import QIcon
from PyQt5.QtWidgets import qApp


class Ui_MainWindow(object):
    def setupUi(self, MainWindow):
      ....(qtdesigner codes . i skip this part)


        self.pushButton.clicked.connect(self.cevirici)
        self.pushButton_2.clicked.connect(self.cikis)

        self.retranslateUi(MainWindow)
        QtCore.QMetaObject.connectSlotsByName(MainWindow)

    def retranslateUi(self, MainWindow):
        _translate = QtCore.QCoreApplication.translate
        MainWindow.setWindowTitle(_translate("MainWindow", "MainWindow"))
        self.label_2.setText(_translate("MainWindow", "Birinci D?viz"))
        self.label.setText(_translate("MainWindow", "?kinci D?viz"))
        self.label_3.setText(_translate("MainWindow", "Miktar"))
        self.label_4.setText(_translate("MainWindow", "Sonu? :"))
        self.pushButton.setText(_translate("MainWindow", "?evir"))
        self.pushButton_2.setText(_translate("MainWindow", "??k?? Yap"))

    def cevirici(self):
        import requests

        import sys

        url = "http://api.fixer.io/latest?base="

        birinci_doviz = self.comboBox.currentText()
        ikinci_doviz = self.comboBox_2.currentText()

        miktar = int(self.lineEdit.currentText())

        response = requests.get(url + birinci_doviz)

        json_verisi = response.json()


        self.lineEdit_2.setText(json_verisi["rates"][ikinci_doviz] * miktar)
    def cikis(self):
        qApp.quit()    

if __name__ == "__main__":
    import sys
    app = QtWidgets.QApplication(sys.argv)
    MainWindow = QtWidgets.QMainWindow()
    ui = Ui_MainWindow()
    ui.setupUi(MainWindow)
    MainWindow.show()
    sys.exit(app.exec_())

回答by user3483203

0and 1are exit codes, and they are not necessarily python specific, in fact they are very common.

01是退出代码,它们不一定是特定于python的,实际上它们很常见。

exit code (0)means an exit without an errors or issues.

exit code (0)表示没有错误或问题的退出。

exit code (1)means there was some issue / problem which caused the program to exit.

exit code (1)意味着有一些问题/问题导致程序退出。

The effect of each of these codes can vary between operating systems, but with Python should be fairly consistent.

这些代码中的每一个的效果可能因操作系统而异,但 Python 应该相当一致。

回答by Ashish Kumar

0and 1are exit codes.

01是退出代码。

exit code (0)means an exit without an errors or any issues, can be a compile time error or any dependency issue.

exit code (0)意味着没有错误或任何问题的退出,可能是编译时错误或任何依赖问题。

exit code (1)means there was some issue which caused the program to exit. For example if your program is running on port :8080and that port is currently in used or not closed, then you code ends up with exit code 1

exit code (1)意味着有一些问题导致程序退出。例如,如果您的程序正在运行port :8080并且该端口当前正在使用或未关闭,那么您的代码最终会exit code 1