[Python]예외처리
파이썬 예외처리
예외처리의 구조
Try-Except문
1
2
3
4
5
6
7
8
try:
#원래 실행하려는 코드
except:
#예외 처리시 실행하려는 코드
else:
#예외가 발생되지 않음
finally:
#마무리
Raise
1
2
3
4
class custom_Error(Exception):
pass
raise custom_Error
1
1
2
3
4
5
6
7
8
try:
#원래 실행하려는 코드
except:
#예외 처리시 실행하려는 코드
else:
#예외가 발생되지 않음
finally:
#마무리
1
2
3
4
class custom_Error(Exception):
pass
raise custom_Error
1