except:
@ Introducing Python: Modern Computing in Simple Packages by Bill Lubanovic (No. 2903 / 12833)
Verwendung von "try:" und "außer:" wird veröffentlicht.
Ich habe es versucht.
http://ideone.com/mhkPBd
alist = [ '7of9', 'Janeway', "B'Elanna Torres" ]
position = 5
try:
print(alist[position])
except:
print("Position is out of range")
run
Position is out of range
except exceptiontype as name:
@ Introducing Python: Modern Computing in Simple Packages by Bill Lubanovic (No. 2919 / 12833)
Ich habe es versucht.
http://ideone.com/rhOmZ8
alist = [ '7of9', 'Janeway', "B'Elanna Torres" ]
position = 5
try:
print(alist[position])
except IndexError as err:
print("Position is out of range")
except Exception as other:
print("Something doesn't sit right well.")
run
Position is out of range
Referenz: 5. Integrierte Ausnahmen @ Python >> 3.6.1 >> Dokumente >> Python-Standardbibliothek
Recommended Posts