what's the use case of exit() and sys.exit() in python
In main():
It's recommand to use exit()
In function/modules
It's recommand o use sys.exit().
Need to deal with the return code.
Unlike exit(), sys.exit() is considered good to be used in production code for the sys module is always available. The optional argument arg can be an integer giving the exit or another type of object. If it is an integer, zero is considered “successful termination”.
Note: A string can also be passed to the sys.exit() method.
Reference:
https://www.geeksforgeeks.org/python-exit-commands-quit-exit-sys-exit-and-os-_exit/
好的心态+正确的方法
浙公网安备 33010602011771号