Sometimes, we want to terminate a script with Python
in this article, we’ll look at how to terminate a script with Python.
How to terminate a script with Python?
To terminate a script with Python, we can call sys.exit
.
For instance, we write
import sys
sys.exit()
to call sys.exit
with an optional exit code argument.
If we call it with anything other than 0, we exit the script with an abnormal termination.
Conclusion
To terminate a script with Python, we can call sys.exit
.