Python os._exit () sys.exit ()

Source: Internet
Author: User

Os._exit () will terminate the Python program directly, and all subsequent code will not continue to execute.

Sys.exit () throws an exception: Systemexit, if the exception is not captured, the Python interpreter exits. If there is code to catch this exception, the code will still execute. Catching this exception can do some extra cleanup work. 0 for normal exit, other values (1-127) are not normal, can throw abnormal events for capture.

Generally os._exit () is used to exit in the thread
Sys.exit () is used to exit from the main thread.

Exit (0): no error exits
Exit (1): There was an error exiting
The exit code tells the interpreter (or the operating system)

Python os._exit () sys.exit ()

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.