{"id":2728,"date":"2025-09-03T14:57:55","date_gmt":"2025-09-03T05:57:55","guid":{"rendered":"https:\/\/mindtech.jp\/?p=2728"},"modified":"2025-09-03T14:57:56","modified_gmt":"2025-09-03T05:57:56","slug":"post-2728","status":"publish","type":"post","link":"https:\/\/mindtech.jp\/?p=2728","title":{"rendered":"Jupyternotebook\u306e\u30bb\u30eb\u306bsys.exit() \u3092\u5165\u308c\u3066\u51e6\u7406\u304c\u4e0d\u5b89\u5b9a\u306b\u306a\u3063\u305f\u8a71"},"content":{"rendered":"\n<p>\u30d5\u30a1\u30a4\u30eb\u3084API\u547c\u3073\u51fa\u3057\u3057\u305fJSON\u5f62\u5f0f\u306e\u30c7\u30fc\u30bf\u3092\u52a0\u5de5\u3057\u3066\u3044\u305f\u969b\u306b\u3001\u65e2\u5b58\u306ePython \u30b9\u30af\u30ea\u30d7\u30c8\u304b\u3089\u52a0\u5de5\u7528\u306e\u95a2\u6570\u3092\u6301\u3063\u3066\u304d\u3066\u4f7f\u3063\u3066\u304a\u308a\u307e\u3057\u305f\u3089\u3001\u3069\u3046\u3082\u91cd\u8907\u30c7\u30fc\u30bf\u304c\u767a\u751f\u3057\u3066\u3044\u305f\u308a\u3068\u3001\u5143\u30cd\u30bf\u306e\u30c1\u30a7\u30c3\u30af\u3092\u542b\u3081\u3066\u78ba\u8a8d\u3057\u3066\u3044\u305f\u3068\u3053\u308d\u3001\u52a0\u5de5\u51e6\u7406\u3092\u30c7\u30d0\u30c3\u30b0print\u3092\u8ffd\u52a0\u3057\u3066\u5b9f\u884c\u3055\u305b\u3066\u304a\u3063\u305f\u3089\u3001\u30b3\u30fc\u30c9\u4e2d\u306f\u51e6\u7406\u9806\u304c<\/p>\n\n\n\n<p>STEP1 &#8211; <br>STEP1 END<br>STEP2<br>STEP2 END<br>STEP3<br>&#8230;<br>\u3068\u66f8\u3044\u3066\u3042\u308b\u3068\u3053\u308d\u3001\u5b9f\u884c\u30ed\u30b0\u3092\u898b\u308b\u3068<\/p>\n\n\n\n<p>STEP1<br>STEP2<br>STEP2 END<br>STEP2<br>STEP2 END<br>STEP1 END<br>&#8230;<\/p>\n\n\n\n<p>\u3068\u306a\u3063\u3066\u3044\u3066\u3001\u982d\u3092\u62b1\u3048\u3066\u304a\u3063\u305f\u308f\u3051\u3067\u3059\u3002\u30b7\u30f3\u30d7\u30eb\u306b\u9010\u6b21\u51e6\u7406\u3092\u3055\u305b\u3066\u3044\u308b\u3060\u3051\u306a\u306e\u306b\u3001\u306a\u305c\u306b\u51e6\u7406\u304c\u524d\u5f8c\u3059\u308b\u306e\u304b\u8a33\u304c\u5206\u304b\u3089\u306a\u3044\u308f\u3051\u3067\u3059\u3002\u8a18\u9332\u3092\u898b\u308c\u3070STEP2\u3067\u4f5c\u6210\u3057\u3066\u3044\u308b\u30ec\u30b3\u30fc\u30c9\u304c\u91cd\u8907\u3057\u3066\u3057\u307e\u3046\u308f\u3051\u3067\u3001\u305d\u3053\u306e\u8b0e\u304c\u89e3\u3051\u305f\u308f\u3051\u3067\u3059\u304c\u3001\u30eb\u30fc\u30d7\u3069\u3053\u308d\u304b\u5236\u5fa1\u6587\u304c\u5165\u3063\u3066\u3044\u306a\u3044\u306e\u306b\u306a\u305c\u51e6\u7406\u304c\u30eb\u30fc\u30d7\u3059\u308b\u306e\u304b\u8b0e\u3067\u3057\u305f\u3002<\/p>\n\n\n\n<p>\u5404\u30b9\u30c6\u30c3\u30d7\u3067\u306f\u5225\u306e\u52d5\u4f5c\u4e2d\u306e\u30b9\u30af\u30ea\u30d7\u30c8\u304b\u3089\u95a2\u6570\u3092\u6301\u3063\u3066\u304d\u3066\u51e6\u7406\u3092\u3055\u305b\u3066\u304a\u3063\u305f\u308f\u3051\u3067\u3059\u304c\u3001\u305d\u3053\u306b\u542b\u307e\u308c\u3066\u3044\u305f sys.exit() \u304c\u30a2\u30e4\u30b7\u30a4\u611f\u3058\u3067\u3057\u305f\u3002<\/p>\n\n\n\n<p>\u30b3\u30fc\u30c9\u3092GPT-5\u306b\u98df\u308f\u305b\u3066\u3001\u539f\u56e0\u3092\u805e\u3044\u3066\u307f\u307e\u3059\u3068\u6b21\u306e\u3088\u3046\u306a\u3054\u795e\u8a17\u304c\u3002<\/p>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p>Jupyter Notebook \u3067 sys.exit() \u3092\u4f7f\u3046\u3068\u3001SystemExit \u4f8b\u5916\u304c\u767a\u751f\u3057\u3001\u901a\u5e38\u306f\u300c\u305d\u306e\u30bb\u30eb\u306e\u5b9f\u884c\u304c\u4e2d\u65ad\u300d\u3055\u308c\u307e\u3059\u3002\u3057\u304b\u3057\u3001for \u30eb\u30fc\u30d7\u3084\u95a2\u6570\u547c\u3073\u51fa\u3057\u306e\u4e2d\u3067 sys.exit() \u304c\u767a\u751f\u3057\u305f\u5834\u5408\u3001\u4f8b\u5916\u304c\u3046\u307e\u304f\u4f1d\u64ad\u3057\u306a\u3044\u3053\u3068\u304c\u3042\u308a\u307e\u3059\u3002<\/p>\n\n\n\n<p>\u7279\u306b Notebook \u3067\u306f\u3001\u30bb\u30eb\u306e\u5b9f\u884c\u304c\u300c\u5185\u90e8\u7684\u306b try-except \u3067\u30e9\u30c3\u30d7\u300d\u3055\u308c\u3066\u3044\u308b\u305f\u3081\u3001sys.exit() \u306e\u4f8b\u5916\u304c\u5b8c\u5168\u306b\u30ab\u30fc\u30cd\u30eb\u3092\u7d42\u4e86\u305b\u305a\u3001\u30bb\u30eb\u306e\u5b9f\u884c\u304c\u9014\u4e2d\u3067\u6b62\u307e\u3063\u305f\u308a\u3001\u90e8\u5206\u7684\u306b\u6b8b\u3063\u305f\u51e6\u7406\u304c\u518d\u5ea6\u5b9f\u884c\u3055\u308c\u305f\u308a\u3059\u308b\u3053\u3068\u304c\u3042\u308a\u307e\u3059\u3002<\/p>\n\n\n\n<p>\u305d\u306e\u7d50\u679c\u3001\u4ee5\u4e0b\u306e\u3088\u3046\u306a\u73fe\u8c61\u304c\u8d77\u3053\u308a\u307e\u3059\uff1a<\/p>\n\n\n\n<p>sys.exit() \u3067\u4e00\u5ea6\u6b62\u307e\u3063\u305f\u306f\u305a\u306e\u51e6\u7406\u304c\u3001\u30bb\u30eb\u306e\u518d\u5b9f\u884c\u3084\u30eb\u30fc\u30d7\u306e\u9014\u4e2d\u3067\u518d\u5ea6\u547c\u3070\u308c\u308b<br>print\u6587\u306e\u51fa\u529b\u9806\u5e8f\u304c\u4e71\u308c\u308b\uff08STEP1, STEP2, STEP2, STEP1 END \u306a\u3069\uff09<br>\u30eb\u30fc\u30d7\u3084\u95a2\u6570\u306e\u4e2d\u3067\u4f8b\u5916\u304c\u30ad\u30e3\u30c3\u30c1\u3055\u308c\u3066\u3044\u308b\u3068\u3001\u51e6\u7406\u304c\u7e70\u308a\u8fd4\u3055\u308c\u308b<br>\u3053\u308c\u306f\u3001Notebook \u306e\u30bb\u30eb\u5b9f\u884c\u304c\u300cPython\u30b9\u30af\u30ea\u30d7\u30c8\u306e\u5b9f\u884c\u300d\u3068\u306f\u7570\u306a\u308a\u3001\u30ab\u30fc\u30cd\u30eb\u5168\u4f53\u3092\u7d42\u4e86\u3057\u306a\u3044\u305f\u3081\u3001\u4f8b\u5916\u306e\u4f1d\u64ad\u3084\u72b6\u614b\u7ba1\u7406\u304c\u8907\u96d1\u306b\u306a\u308b\u305f\u3081\u3067\u3059\u3002<\/p>\n\n\n\n<p>\u5bfe\u7b56\uff1a<\/p>\n\n\n\n<p>Notebook \u3067\u306f sys.exit() \u306e\u4f7f\u7528\u3092\u907f\u3051\u3001return \u3084 raise Exception \u3067\u660e\u793a\u7684\u306b\u51e6\u7406\u3092\u6b62\u3081\u308b\u65b9\u304c\u5b89\u5168\u3067\u3059\u3002<br>sys.exit() \u3092\u4f7f\u3046\u5834\u5408\u306f\u3001\u4f8b\u5916\u304c\u3069\u3053\u3067\u30ad\u30e3\u30c3\u30c1\u3055\u308c\u308b\u304b\u3001\u30eb\u30fc\u30d7\u3084\u95a2\u6570\u306e\u5916\u306b\u6b63\u3057\u304f\u4f1d\u64ad\u3059\u308b\u304b\u3092\u78ba\u8a8d\u3057\u3066\u304f\u3060\u3055\u3044\u3002<br>\u3053\u306e\u73fe\u8c61\u306f Notebook \u7279\u6709\u306e\u3082\u306e\u3067\u3059\u3002\u901a\u5e38\u306e Python \u30b9\u30af\u30ea\u30d7\u30c8\u3067\u306f\u8d77\u3053\u308a\u307e\u305b\u3093\u3002<\/p>\n<\/blockquote>\n\n\n\n<p>\u672c\u6765\u3042\u308b\u306f\u305a\u306e\u6307\u5b9a\u306e\u6761\u4ef6\u306e\u30c7\u30fc\u30bf\u304c\u898b\u3064\u304b\u3089\u306a\u304b\u3063\u305f\u5834\u5408\u306b\u3001sys.exit() \u3092\u547c\u3073\u51fa\u3057\u3066\u30b9\u30af\u30ea\u30d7\u30c8\u3092\u6b62\u3081\u3066\u3044\u305f\u308f\u3051\u3067\u3059\u304c\u3001\u5b9f\u884c\u30ed\u30b0\u3092\u898b\u308b\u3068\u3053\u306e\u500b\u6240\u306f\u547c\u3073\u51fa\u3055\u308c\u3066\u3044\u306a\u304b\u3063\u305f\u308f\u3051\u3067\u3059\u304c\u3001sys.exit() \u3092\u30b3\u30e1\u30f3\u30c8\u30a2\u30a6\u30c8\u3057\u3066\u518d\u5b9f\u884c\u3057\u3066\u307f\u308b\u3068\u3001\u78ba\u304b\u306b STEP1, STEP2, STEP3, &#8230; \u3068\u6de1\u3005\u3068\u6b63\u5e38\u306b\u51e6\u7406\u3055\u308c\u3066\u3044\u304f\u308f\u3051\u3067\u3059\u3002<\/p>\n\n\n\n<p>\u4f8b\u5916\u3092\u30ad\u30e3\u30c3\u30c1\u3057\u3066 sys.exit() \u304c\u547c\u3070\u308c\u3066\u51e6\u7406\u304c\u4e0d\u5b89\u5b9a\u306b\u306a\u308b\u306a\u3089\u5206\u304b\u308b\u306e\u3067\u3059\u304c\u3001\u3053\u308c\u304c\u66f8\u3044\u3066\u3042\u308b\u3060\u3051\u3067\u3001\u51e6\u7406\u304c\u4e0d\u5b89\u5b9a\u306b\u306a\u308b\u3068\u304b\u610f\u5473\u304c\u5206\u304b\u308a\u307e\u305b\u3093\u3002\u3050\u306c\u306c\u3002<\/p>\n\n\n\n<p>\u3044\u305a\u308c\u306b\u305b\u3088\u3001Jupyter Notebook\u3067\u306esys.exit() \u304c\u546a\u3044\u306e\u8a00\u8449\u3060\u3068\u5206\u304b\u3063\u305f\u306e\u3067\u3001\u3054\u795e\u8a17\u306e\u901a\u308a\u306b raise Exception\u306a\u3069\u3067\u66f8\u304d\u63db\u3048\u3066\u3001\u51e6\u7406\u304c\u6d41\u308c\u308b\u3068\u3053\u308d\u307e\u3067\u78ba\u8a8d\u3067\u304d\u307e\u3057\u305f\u3002<\/p>\n\n\n\n<p>\u30af\u30bd\u5fd9\u3057\u3044\u306e\u3067\u6df1\u5800\u3067\u304d\u307e\u305b\u3093\u3067\u3057\u305f\u304c\u3001\u306a\u3093\u306a\u306e\u3053\u308c\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u30d5\u30a1\u30a4\u30eb\u3084API\u547c\u3073\u51fa\u3057\u3057\u305fJSON\u5f62\u5f0f\u306e\u30c7\u30fc\u30bf\u3092\u52a0\u5de5\u3057\u3066\u3044\u305f\u969b\u306b\u3001\u65e2\u5b58\u306ePython \u30b9\u30af\u30ea\u30d7\u30c8\u304b\u3089\u52a0\u5de5\u7528\u306e\u95a2\u6570\u3092\u6301\u3063\u3066\u304d\u3066\u4f7f\u3063\u3066\u304a\u308a\u307e\u3057\u305f\u3089\u3001\u3069\u3046\u3082\u91cd\u8907\u30c7\u30fc\u30bf\u304c\u767a\u751f\u3057\u3066\u3044\u305f\u308a\u3068\u3001\u5143\u30cd\u30bf\u306e\u30c1\u30a7\u30c3\u30af\u3092\u542b\u3081\u3066\u78ba\u8a8d\u3057\u3066\u3044\u305f\u3068 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[1],"tags":[479,34],"class_list":["post-2728","post","type-post","status-publish","format-standard","hentry","category-1","tag-jupyternotebook","tag-python"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p4rHn0-I0","amp_enabled":true,"_links":{"self":[{"href":"https:\/\/mindtech.jp\/index.php?rest_route=\/wp\/v2\/posts\/2728","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/mindtech.jp\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/mindtech.jp\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/mindtech.jp\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/mindtech.jp\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=2728"}],"version-history":[{"count":1,"href":"https:\/\/mindtech.jp\/index.php?rest_route=\/wp\/v2\/posts\/2728\/revisions"}],"predecessor-version":[{"id":2729,"href":"https:\/\/mindtech.jp\/index.php?rest_route=\/wp\/v2\/posts\/2728\/revisions\/2729"}],"wp:attachment":[{"href":"https:\/\/mindtech.jp\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=2728"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mindtech.jp\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=2728"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mindtech.jp\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=2728"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}