Difference between exit(0) and exit(1) in Python

前端 未结 5 1540
没有蜡笔的小新
没有蜡笔的小新 2020-11-29 16:27

What\'s the difference between exit(0) and exit(1) in Python?

I tried looking around but didn\'t find a specific question on these lines. I

5条回答
  •  迷失自我
    2020-11-29 17:18

    The standard convention for all C programs, including Python, is for exit(0) to indicate success, and exit(1) or any other non-zero value (in the range 1..255) to indicate failure. Any value outside the range 0..255 is treated modulo 256 (the exit status is stored in an 8-bit value). Sometimes, that will be treated as signed (so you might see -128, -127, etc) but more usually it is treated as unsigned.

    This status is available to the code that invoked Python. This convention applies across platforms, though the meaning of non-zero exit status can vary on different platforms.

提交回复
热议问题