tryæ§æ(ã¨ã©ã¼å¦ç)
ä¾å¤å¦çã¨ãã¨ã©ã¼ãã©ãããªã©ã¨å¼ã°ãããã¤ã
â¼æ¸å¼
try: ãã®ä¸ã§ã¨ã©ã¼ãèµ·ããã except: ããã®å¦çãè¡ã
â¼ä½¿ãæ¹
>>> ========================= RESTART ========================= >>> def test1(a, b): c = a + b print c >>> test1(1, "hello") #test1é¢æ°ã®ãªãã§æ°åã¨æååã足ããã¨ã«ãªãã Traceback (most recent call last): File "", line 1, in -toplevel- test1(1, "hello") File " ", line 2, in test1 c = a + b TypeError: unsupported operand type(s) for +: 'int' and 'str' >>> def test2(a, b): try: c = a + b print c except TypeError: print "ã¨ã©ã¼ãã§ãã" >>> test2(1, "hello") ã¨ã©ã¼ãã§ãã åè:8. ã¨ã©ã¼ã¨ä¾å¤ http://www.python.jp/doc/release/tut/node10.html