{"id":1975,"date":"2018-09-21T12:39:56","date_gmt":"2018-09-21T03:39:56","guid":{"rendered":"https:\/\/www.dogrow.net\/python\/?p=1975"},"modified":"2019-10-20T03:34:33","modified_gmt":"2019-10-19T18:34:33","slug":"blog105","status":"publish","type":"post","link":"https:\/\/www.dogrow.net\/python\/blog105\/","title":{"rendered":"(105) \u72ec\u81ea\u5b9a\u7fa9\u306e\u4f8b\u5916\u3092\u767a\u751f\u3055\u305b\u308b\u3002"},"content":{"rendered":"<p><span class=\"my_fc_deeppinkBBig\">throw<\/span> \u3058\u3083\u306a\u304f\u3066 <span class=\"my_fc_deeppinkBBig\">raise<\/span> \u3068\u66f8\u304f\u3002<\/p>\n<pre class=\"brush: python; title: ; notranslate\" title=\"\">\r\n########################################################################\r\nclass MyError(Exception):\r\n    pass\r\n\r\n########################################################################\r\ndef check_number( n ):\r\n    ret = False\r\n    try:\r\n        if n &lt; 10 :\r\n            raise MyError('%d is too small' % n)\r\n        if n &gt; 100 :\r\n            raise MyError('%d is too big' % n)\r\n        ret = True\r\n    except MyError as e:\r\n        print('&lt;p style=&quot;color:#f00&quot;&gt;%s&lt;\/p&gt;' % e.message)\r\n    return ret\r\n<\/pre>\n<p>\u5b9f\u884c\u3057\u3066\u307f\u308b\u3002<\/p>\n<pre class=\"brush: python; title: ; notranslate\" title=\"\">\r\n&gt;&gt;&gt; check_number(1)\r\n&lt;p style=&quot;color:#f00&quot;&gt;1 is too small&lt;\/p&gt;\r\nFalse\r\n&gt;&gt;&gt;\r\n&gt;&gt;&gt; check_number(50)\r\nTrue\r\n&gt;&gt;&gt;\r\n&gt;&gt;&gt; check_number(200)\r\n&lt;p style=&quot;color:#f00&quot;&gt;200 is too big&lt;\/p&gt;\r\nFalse\r\n<\/pre>\n<hr class=\"my_hr_bottom\">\n","protected":false},"excerpt":{"rendered":"<p>throw \u3058\u3083\u306a\u304f\u3066 raise \u3068\u66f8\u304f\u3002 ######################################################################## class MyError(\u2026 <span class=\"read-more\"><a href=\"https:\/\/www.dogrow.net\/python\/blog105\/\">\u7d9a\u304d\u3092\u8aad\u3080 &raquo;<\/a><\/span><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[38],"tags":[],"class_list":["post-1975","post","type-post","status-publish","format-standard","hentry","category-exception"],"views":6495,"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/www.dogrow.net\/python\/wp-json\/wp\/v2\/posts\/1975","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.dogrow.net\/python\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.dogrow.net\/python\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.dogrow.net\/python\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.dogrow.net\/python\/wp-json\/wp\/v2\/comments?post=1975"}],"version-history":[{"count":8,"href":"https:\/\/www.dogrow.net\/python\/wp-json\/wp\/v2\/posts\/1975\/revisions"}],"predecessor-version":[{"id":2737,"href":"https:\/\/www.dogrow.net\/python\/wp-json\/wp\/v2\/posts\/1975\/revisions\/2737"}],"wp:attachment":[{"href":"https:\/\/www.dogrow.net\/python\/wp-json\/wp\/v2\/media?parent=1975"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.dogrow.net\/python\/wp-json\/wp\/v2\/categories?post=1975"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.dogrow.net\/python\/wp-json\/wp\/v2\/tags?post=1975"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}