What is difference between sys.exit(0) and os._exit(0)

前端 未结 2 576
梦谈多话
梦谈多话 2020-12-04 16:12

Please help me in clarifying the concept of these two python statements in terms of difference in functionality:

  1. sys.exit(0)

2条回答
  •  甜味超标
    2020-12-04 16:56

    os._exit calls the C function _exit() which does an immediate program termination. Note the statement "can never return".

    sys.exit() is identical to raise SystemExit(). It raises a Python exception which may be caught by the caller.

    Original post: http://bytes.com/topic/python/answers/156121-os-_exit-vs-sys-exit

提交回复
热议问题