Quantcast
Channel: sr's lair
Viewing all articles
Browse latest Browse all 687

[python3] 예외 이름 출력하기

$
0
0
<p data-ke-size="size16">기록용으로 남깁니다.</p> <p data-ke-size="size16"> </p> <p data-ke-size="size16">간혹 현재 발생한 예외의 이름을 검사할 필요한 때가 있습니다.</p> <p data-ke-size="size16">이 때에는 다음과 같이 접근할 수 있습니다.</p> <p data-ke-size="size16"> </p> <pre id="code_1707980701975" class="bash" data-ke-language="bash" data-ke-type="codeblock"><code>try: # ... except Exception as e: print(type(e).__name__) print(e.__class__.__name__) print(e.__class__.__qualname__)</code></pre> <p data-ke-size="size16">위 3개 중에 하나만 사용해도 됩니다. </p>

Viewing all articles
Browse latest Browse all 687

Trending Articles