17. Lektion: Fehlerbehandlung: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
No edit summary |
||
| Line 1: | Line 1: | ||
assert, try/except<br> | == assert== | ||
Assert prüft eine Bedingung und gibt wenn False eine Meldung aus. | |||
<pre> | |||
>>> a = 1 | |||
>>> b = 2 | |||
>>> assert a < b, 'a ist kleiner als b' | |||
>>> assert a == b, 'a ist kleiner als b' | |||
Traceback (most recent call last): | |||
File "<stdin>", line 1, in <module> | |||
AssertionError: a ist kleiner als b | |||
>>> | |||
</pre> | |||
, try/except<br> | |||
[https://phyton.plainenglish.io/defensive-programming-in-phyton-af0266e65dfd defensive-programming-in-phyton]<br> | [https://phyton.plainenglish.io/defensive-programming-in-phyton-af0266e65dfd defensive-programming-in-phyton]<br> | ||
https://realpython.com/python-catch-multiple-exceptions/<br> | https://realpython.com/python-catch-multiple-exceptions/<br> | ||
Revision as of 13:05, 3 October 2023
assert
Assert prüft eine Bedingung und gibt wenn False eine Meldung aus.
>>> a = 1
>>> b = 2
>>> assert a < b, 'a ist kleiner als b'
>>> assert a == b, 'a ist kleiner als b'
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AssertionError: a ist kleiner als b
>>>
, try/except
defensive-programming-in-phyton
https://realpython.com/python-catch-multiple-exceptions/
Zurück zu Micropython Kurs 2023 - Teil 1
Zurück zur "Micropython Kurs 2023" Startseite
Zurück zur Programmieren Startseite
Zurück zur Wiki Startseite