開発環境
- OS X Lion - Apple(OS)
- BBEdit - Bare Bones Software, Inc., Emacs(Text Editor)
- プログラミング言語: Python
『初めてのPython 第3版』(Mark Lutz 著、夏目 大 訳、オライリー・ジャパン、2009年、ISBN978-4-87311-393-7)のVII部(例外)、28章(クラス例外)の練習問題4を解いてみる。
その他参考書籍
4.
sample.py
#!/usr/bin/env python3.3 #-*- coding: utf-8 -*- def f(): raise Exception("エラーメッセージ") if __name__ == '__main__': try: f() except Exception as err: print(type(err), err, err.args)
入出力結果(Terminal)
$ ./sample.py <class 'Exception'> エラーメッセージ ('エラーメッセージ',) $
0 コメント:
コメントを投稿