[Python응용] 9. 함수에서 에러가 발생하는 경우
파이썬의 대표적인 에러에 대해 학습
- 인덱스 첨자 범위를 벗어난 경우
a = [10, 20, 30] a[3] Traceback (most recent call last): File "<stdin>", line 1, in <module> IndexError: list index out of range
- 형식이 잘못된 경우
result = 5/'string' Traceback (most recent call last): File "<stdin>", line 1, in <module> TypeError: unsupported operand type(s) for /: 'int' and 'str'
에러 처리를 위한 클래스 계층
- 에러 처리를 하는 다양한 에러 클래스가 제공
BaseException SystemExit Exception StopIteration ArithmeticError ...