PyCharm: Process finished with exit code 0

前端 未结 9 1927
感情败类
感情败类 2021-02-13 16:51

I am new to PyCharm and I have \'Process finished with exit code 0\' instead of getting (683, 11) as a result (please see attachment), could you guys help me out please? Much ap

9条回答
  •  情话喂你
    2021-02-13 17:26

    exit code 0 means you code run with no error.

    Let's give a error code for example(clearly in the below image): in below code, the variable lst is an empty list, but we get the 5 member in it(which not exists), so the program throws IndexError, and exit 1 which means there is error with the code.

    You can also define exit code for analysis, for example:

    ERROR_USERNAME, ERROR_PASSWORD, RIGHT_CODE = 683, 11, 0
    right_name, right_password = 'xy', 'xy'
    
    name, password = 'xy', 'wrong_password'
    
    if name != right_name:
        exit(ERROR_USERNAME)
    
    if password != right_password:
        exit(ERROR_PASSWORD)
    
    exit(RIGHT_CODE)
    

提交回复
热议问题