Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | ||
6 | 7 | 8 | 9 | 10 | 11 | 12 |
13 | 14 | 15 | 16 | 17 | 18 | 19 |
20 | 21 | 22 | 23 | 24 | 25 | 26 |
27 | 28 | 29 | 30 |
Tags
- data structure
- github
- javascript
- control
- for
- Java
- function
- MacOS
- CSS
- Linux
- system
- architecture
- while
- html
- mysql
- react
- DATAPATH
- php
- Algorithm
- MIPS
- Class
- python
- computer
- instruction
- XML
- DB
- DS
- web
- DoM
- Pipelining
Archives
- Today
- Total
YYYEJI
[Python] 예외처리 본문
728x90

파이썬에서 예외처리하는 방법을 알아봅시다.
EXCEPTION
• try: try 구문에서 코드가 실행되는데 참이면 except 구문을 건너띄고, 아니면 except 구문이 실행됩니다.
• except: try 구문이 참인지 거짓인지에 따라 except 구문의 실행 여부가 결정됩니다.
• finally: try 구문의 코드가 참인지 거짓인지의 여부에 상관없이 실행됩니다.
try:
num = int(input("num > "))
except:
print("It's not a number")
finally:
print("==> Program End")

✓ try 구문이 거짓이기 때문에 except 구문이 실행됩니다.

✓ try 구문이 참이기 때문에 except 구문이 실행되지 않습니다.
◡̈
'Python' 카테고리의 다른 글
[Python] Streamlit (0) | 2022.11.21 |
---|---|
[Python] Tkinter (0) | 2022.11.21 |
[Python] 파일 다루기 (2) | 2022.11.19 |
[MacOS] Conda : command not found Error (0) | 2022.11.09 |
[Python] 문자열 형식화 (0) | 2022.11.04 |