First page Back Continue Last page Overview Image

Methode zum Beenden

Das Modul sys liefert auch eine Methode, um ein Python-Programm von selbst vorzeitig zu beenden:

>>> import sys

>>> sys.exit()

Alternativ:

raise SystemExit

sys.exit() erhebt (raises) die SystemExit-Ausnahme.

Wird diese Ausnahme nicht behandelt, endet der Python-Interpreter ohne stack traceback.

If the associated value is a plain integer, it specifies the system exit status; if it is None, the exit status is zero; if it has another type (such as a string), the object’s value is printed and the exit status is one.

Another way to exit: quit()