import sys
try:
print("1")
raise ValueError("test")
print("2") # 実行されない
except ValueError:
print(sys.exception()) # "ftest"と出力
print("3")
例外の情報は、sys.exception()で取得できます。8.4.1. except 節 - 8. 複合文 (compound statement) — Python 3.x ドキュメント