James Chen, CMT is an expert trader, investment adviser, and global market strategist. Eric's career includes extensive work in both public and corporate accounting with responsibilities such as ...
try / except 기본 — 예외를 잡는 여러 방법. except 절에 예외 종류를 지정하거나, 여러 예외를 한 번에 묶을 수 있다. 빈 except: 는 KeyboardInterrupt 까지 잡아 프로그램을 죽기 힘들게 만드니 쓰지 않는다.
파이썬 예외 계층 구조와 자주 만나는 예외들. BaseException → Exception → 각종 구체 예외 순으로 상속된다. 자식 예외는 부모 except 절로도 잡히므로 넓은 except 는 신중하게 써야 한다.