Answers for "sys.exit in python"

1

why doesn't sys.exit work?

import sys

try:
    sys.exit() # this always raises SystemExit
except SystemExit:
    print("sys.exit() worked as expected")
except:
    print("Something went horribly wrong") # some other exception got raised
Posted by: Guest on June-17-2020
8

exit in python

import sys
msg = "bye bye"
sys.exit(msg)
# you can use it with out a msg
Posted by: Guest on May-09-2020

Python Answers by Framework

Browse Popular Code Answers by Language