본문 바로가기

교육/Python 0309-0313

06. 예외처리

예외처리

try :

statement

except [예외 타입 as 예외 변수] :

예외 발생 시 statement

[else :

예외 발생안하면 statement

finally:

예외발생유무와 상관없이 수행될 statement]


raise 예외

raise 예외(데이터)


Exception 을 상속받아 사용자 정의 예외 class를 만들 수 있음


예외 종류
Exception
 SystemExit
 StopIteration
 SandardError
  ArithmeticError
   FloatingPointError
   OverflowError
   ZeroDivisionError
  AssertionError
  AttributeError
  EnvironmentError
   IOError
   OSError
  EOFError
  ImportError
  KeyboardInterrupt
  LookupError
   IndexError
   KeyError
  MemoryError
  NameError
   UnboundLocalError
  ReferenceError
  RuntimeError
   NotImplementedError
  SyntaxError
   IndentationError
    TabError

  SystemError

  TypeError
  ValueError
   UnicodeError
    UnicodedDecodeError
    UnicodedEncodeError
    UnicodedTranslateError


'교육 > Python 0309-0313' 카테고리의 다른 글

08. Library  (0) 2015.03.12
07. File IO  (0) 2015.03.11
05. 상속  (0) 2015.03.11
04. 클래스  (0) 2015.03.11
04. 함수  (0) 2015.03.10