Get the App
SLTechnology News&Howtos  ›  Internet Technology  › 

How to use Python sys.exit ([arg])

Shulou Source: shulou.com Published: 2022-06-01 07:55:36 11月02日 Update

This article introduces the knowledge of "how to use Python sys.exit ([arg])". In the operation of actual cases, many people will encounter such a dilemma, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!

Function description:

Exit the program, passing in the parameter 0 means normal exit. A non-0 parameter passed in indicates an abnormal exit. The incoming string can be used to print error messages.

Examples of code experiments:

Microsoft Windows [version 10.0.18363.1256] (c) 2019 Microsoft Corporation. All rights reserved. C:\ Users\ chenxuqi > conda activate ssd4pytorch2_2_0 (ssd4pytorch2_2_0) C:\ Users\ chenxuqi > pythonPython 3.7.7 (default, May 6 2020, 11:45:54) [MSC v.1916 64 bit (AMD64)]:: Anaconda, Inc. On win32Type "help", "copyright", "credits" or "license" for more information. > > import sys > sys.exit (0) (ssd4pytorch2_2_0) C:\ Users\ chenxuqi > pythonPython 3.7.7 (default, May 6 2020 11:45:54) [MSC v.1916 64 bit (AMD64)]:: Anaconda, Inc. On win32Type "help", "copyright", "credits" or "license" for more information. > > import sys > sys.exit (1) (ssd4pytorch2_2_0) C:\ Users\ chenxuqi > pythonPython 3.7.7 (default, May 6 2020, 11:45:54) [MSC v.1916 64 bit (AMD64)]: Anaconda, Inc. On win32Type "help", "copyright" "credits" or "license" for more information. > > import sys > sys.exit ('program error, early exit, pockmarked Lin!') Program error, early exit, pockmarked Lin!! (ssd4pytorch2_2_0) C:\ Users\ chenxuqi > (ssd4pytorch2_2_0) C:\ Users\ chenxuqi > pythonPython 3.7.7 (default, May 6 2020, 11:45:54) [MSC v.1916 64 bit (AMD64)]:: Anaconda, Inc. On win32Type "help", "copyright" "credits" or "license" for more information. > > import sys > sys.exit ("some error message") some error message (ssd4pytorch2_2_0) C:\ Users\ chenxuqi > (ssd4pytorch2_2_0) C:\ Users\ chenxuqi > (ssd4pytorch2_2_0) C:\ Users\ chenxuqi > "how to use Python sys.exit ([arg])" ends here. Thank you for your reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!

Tags: Programs content parameters more knowledge pockmarked practical learned next code representatives information functions functions dilemmas characters strings actual situation articles Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Linux Apple NVidia Redmi Shulou Information