---------------------------------------------------------------------------
ZeroDivisionError Traceback (most recent call last)
c:\Users\andon\project\python_base\16. 에러와예외처리.ipynb 셀 4 in <cell line: 1>()
----> <a href='vscode-notebook-cell:/c%3A/Users/andon/project/python_base/16.%20%EC%97%90%EB%9F%AC%EC%99%80%EC%98%88%EC%99%B8%EC%B2%98%EB%A6%AC.ipynb#W4sZmlsZQ%3D%3D?line=0'>1</a> raise ZeroDivisionError("숫자를 0으로 나눴습니다")
<a href='vscode-notebook-cell:/c%3A/Users/andon/project/python_base/16.%20%EC%97%90%EB%9F%AC%EC%99%80%EC%98%88%EC%99%B8%EC%B2%98%EB%A6%AC.ipynb#W4sZmlsZQ%3D%3D?line=1'>2</a> # ZeroDivisionError: 숫자를 0으로 나눴습니다
<a href='vscode-notebook-cell:/c%3A/Users/andon/project/python_base/16.%20%EC%97%90%EB%9F%AC%EC%99%80%EC%98%88%EC%99%B8%EC%B2%98%EB%A6%AC.ipynb#W4sZmlsZQ%3D%3D?line=3'>4</a> raise NameError("지역 또는 전역 변수를 찾을 수 없음")
ZeroDivisionError: 숫자를 0으로 나눴습니다
hello
---------------------------------------------------------------------------
MyError Traceback (most recent call last)
c:\Users\andon\project\python_base\16. 에러와예외처리.ipynb 셀 7 in <cell line: 8>()
<a href='vscode-notebook-cell:/c%3A/Users/andon/project/python_base/16.%20%EC%97%90%EB%9F%AC%EC%99%80%EC%98%88%EC%99%B8%EC%B2%98%EB%A6%AC.ipynb#X10sZmlsZQ%3D%3D?line=4'>5</a> print(str)
<a href='vscode-notebook-cell:/c%3A/Users/andon/project/python_base/16.%20%EC%97%90%EB%9F%AC%EC%99%80%EC%98%88%EC%99%B8%EC%B2%98%EB%A6%AC.ipynb#X10sZmlsZQ%3D%3D?line=6'>7</a> say_hi("hello")
----> <a href='vscode-notebook-cell:/c%3A/Users/andon/project/python_base/16.%20%EC%97%90%EB%9F%AC%EC%99%80%EC%98%88%EC%99%B8%EC%B2%98%EB%A6%AC.ipynb#X10sZmlsZQ%3D%3D?line=7'>8</a> say_hi("hi")
c:\Users\andon\project\python_base\16. 에러와예외처리.ipynb 셀 7 in say_hi(str)
<a href='vscode-notebook-cell:/c%3A/Users/andon/project/python_base/16.%20%EC%97%90%EB%9F%AC%EC%99%80%EC%98%88%EC%99%B8%EC%B2%98%EB%A6%AC.ipynb#X10sZmlsZQ%3D%3D?line=0'>1</a> def say_hi(str):
<a href='vscode-notebook-cell:/c%3A/Users/andon/project/python_base/16.%20%EC%97%90%EB%9F%AC%EC%99%80%EC%98%88%EC%99%B8%EC%B2%98%EB%A6%AC.ipynb#X10sZmlsZQ%3D%3D?line=1'>2</a> if str == "hi":
----> <a href='vscode-notebook-cell:/c%3A/Users/andon/project/python_base/16.%20%EC%97%90%EB%9F%AC%EC%99%80%EC%98%88%EC%99%B8%EC%B2%98%EB%A6%AC.ipynb#X10sZmlsZQ%3D%3D?line=2'>3</a> raise MyError()
<a href='vscode-notebook-cell:/c%3A/Users/andon/project/python_base/16.%20%EC%97%90%EB%9F%AC%EC%99%80%EC%98%88%EC%99%B8%EC%B2%98%EB%A6%AC.ipynb#X10sZmlsZQ%3D%3D?line=3'>4</a> else:
<a href='vscode-notebook-cell:/c%3A/Users/andon/project/python_base/16.%20%EC%97%90%EB%9F%AC%EC%99%80%EC%98%88%EC%99%B8%EC%B2%98%EB%A6%AC.ipynb#X10sZmlsZQ%3D%3D?line=4'>5</a> print(str)
MyError:
Error
division by zero
---------------------------------------------------------------------------
ZeroDivisionError Traceback (most recent call last)
c:\Users\andon\project\python_base\16. 에러와예외처리.ipynb 셀 10 in <cell line: 12>()
<a href='vscode-notebook-cell:/c%3A/Users/andon/project/python_base/16.%20%EC%97%90%EB%9F%AC%EC%99%80%EC%98%88%EC%99%B8%EC%B2%98%EB%A6%AC.ipynb#X20sZmlsZQ%3D%3D?line=10'>11</a> # 이 에러는 ZeroDivisionError인데 AttributeError로 처리하면 오류발생
<a href='vscode-notebook-cell:/c%3A/Users/andon/project/python_base/16.%20%EC%97%90%EB%9F%AC%EC%99%80%EC%98%88%EC%99%B8%EC%B2%98%EB%A6%AC.ipynb#X20sZmlsZQ%3D%3D?line=11'>12</a> try:
---> <a href='vscode-notebook-cell:/c%3A/Users/andon/project/python_base/16.%20%EC%97%90%EB%9F%AC%EC%99%80%EC%98%88%EC%99%B8%EC%B2%98%EB%A6%AC.ipynb#X20sZmlsZQ%3D%3D?line=12'>13</a> print(3/0)
<a href='vscode-notebook-cell:/c%3A/Users/andon/project/python_base/16.%20%EC%97%90%EB%9F%AC%EC%99%80%EC%98%88%EC%99%B8%EC%B2%98%EB%A6%AC.ipynb#X20sZmlsZQ%3D%3D?line=13'>14</a> except AttributeError:
<a href='vscode-notebook-cell:/c%3A/Users/andon/project/python_base/16.%20%EC%97%90%EB%9F%AC%EC%99%80%EC%98%88%EC%99%B8%EC%B2%98%EB%A6%AC.ipynb#X20sZmlsZQ%3D%3D?line=14'>15</a> print("AttributeError")
ZeroDivisionError: division by zero
[Errno 2] No such file or directory: 'f.txt'
무조건 실행
미성년자는 출입금지입니다.
입력이 정확하지 않습니다.
댓글남기기