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

前端 未结 2 577
梦谈多话
梦谈多话 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:45

    According to the documentation:

    os._exit():
    

    Exit the process with status n, without calling cleanup handlers, flushing stdio buffers, etc.

    Note The standard way to exit is sys.exit(n). _exit() should normally only be used in the child process after a fork().

提交回复
热议问题