-
[에러/예외처리] Error handling🐍 파이썬/파이썬 기본 문법 2022. 8. 9. 12:15
Python Built-in Exceptions
- IndexError: list index out of range
- ValueError: invalid literal for (e.g. int("a"))
- NameError: name is not defined
- ZeroDivisionError: division by zero
- KeyError: a dictionary key is not found
Raising Exceptions
def do_something_with_number(n): if n < 0 : raise ValueError("negative number is given")
Handling Exception : try / exception statement
Code that can cause an exception is included in a try block.
'🐍 파이썬 > 파이썬 기본 문법' 카테고리의 다른 글
[정수format] 귀찮지만 알면 좋은 다양한 정수 출력 방법 (0) 2022.08.03 [입력/input] 인풋 함수 마스터하기 (0) 2022.08.03 [string/문자열] 문자열 마스터 하기 (0) 2022.08.03 [출력/print] 프린트문 고수되기 (0) 2022.08.03 [inheritance] Multiple Inheritance (0) 2022.07.29