|
try:
a = int('abc')
except ValueError as e:
print('fehlerhafte Zahl')
# IndexError
# ArithmeticError
# EOFError
# IOError
# AttributeError hat kein Instanz hat kein Attribut
# MemoryError
# OverflowError
# ZeroDivisionError
# raise ValueError('represents a hidden bug, do not catch this')
Complet example
try:
a = int('abc')
except ValueError as e1:
print('fehlerhafte Zahl')
except OverflowError as e2:
print('overflowError')
else:
#ausgefuehrt, wenn keine Exception erzeugt wurde
pass
finally:
#immer ausgefuehrt
pass
# raise ValueError('represents a hidden bug, do not catch this')
|
|