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 | 31 |
Tags
- Project
- db
- 참고블로그
- object
- await
- Import
- json
- 게임
- ajax
- Porject
- execCommand
- promise
- 혼프
- js
- slow and steady
- https://youtube.com/playlist?list=PLuHgQVnccGMA5836CvWfieEQy0T0ov6Jh&si=FTaYv8m21EhO-A2K
- webpack
- https://m.blog.naver.com/tt2t2am1118/221010125300
- 비동기
- eport
- async
- setTimeout()
- mysql
- prj
- JS #프로젝트
- callback
- addEventListener
- database
- sql
- 동기
Archives
- Today
- Total
C-log
Welcome to Python : 예외처리 본문
728x90
- 클래스 : https://hi-code.tistory.com/123
- 모듈 : https://hi-code.tistory.com/124
- 패키지 : https://hi-code.tistory.com/125
- 예외 처리 : https://hi-code.tistory.com/126
- 내장 함수 : https://hi-code.tistory.com/127
- 표준 라이브러리 : https://hi-code.tistory.com/128
- 외부 라이브러리 :https://hi-code.tistory.com/129
Title | Code | Console |
try-expect |
try: 4 / 0
except ZeroDivisionError as e:
print(e)
|
division by zero |
try-finally |
try: f = open('foo.txt', 'w')
finally:
f.close
|
|
try-else |
try:
age = int(input('나이를 입력하세요: '))
except:
print('입력이 정확하지 않습니다.')
else:
if age <= 18:
print('미성년자는 출입금지 입니다.')
else:
print('환영합니다.')
|
|
pass |
try: f = open("나없는파일", 'r')
except FileExistsError:
pass
|
|
raise |
class Bird: def fly(self):
raise NotImplementedError
class Eagle(Bird):
pass
eagle = Eagle()
eagle.fly()
|
raise NotImplementedError NotImplementedError |
예외 만들기 |
class MyError(Exception):
pass
def say_nick(nick):
if nick == "바보":
raise MyError()
print(nick)
say_nick("천사")
say_nick("바보")
|
천사 raise MyError() __main__.MyError |
728x90
'📘Python' 카테고리의 다른 글
Welcome to Python : 표준 라이브러리 (0) | 2023.07.27 |
---|---|
Welcome to Python : 내장 함수 (0) | 2023.07.25 |
Welcome to Python : 패키지 (0) | 2023.07.24 |
Welcome to Python : 모듈 (0) | 2023.07.24 |
Welcome to Python : 클래스 (0) | 2023.07.21 |
Comments