{"id":251,"date":"2017-02-02T23:01:34","date_gmt":"2017-02-02T14:01:34","guid":{"rendered":"http:\/\/www.python.ambitious-engineer.com\/?p=251"},"modified":"2021-09-25T20:47:32","modified_gmt":"2021-09-25T11:47:32","slug":"%e9%96%a2%e6%95%b0%e3%81%ae%e5%ae%9a%e7%be%a9","status":"publish","type":"post","link":"https:\/\/www.python.ambitious-engineer.com\/archives\/251","title":{"rendered":"\u95a2\u6570\u306e\u57fa\u672c"},"content":{"rendered":"<p>\u3053\u3053\u304b\u3089\u95a2\u6570\u306b\u3064\u3044\u3066\u89e3\u8aac\u3057\u307e\u3059\u3002Python\u306e\u95a2\u6570\u306e\u8a18\u8ff0\u65b9\u6cd5\u306f\u67d4\u8edf\u3067\u69d8\u3005\u306a\u306e\u3067\u3059\u304c\u3001\u9806\u3092\u8ffd\u3063\u3066\u89e3\u8aac\u3057\u307e\u3059\u3002\u307e\u305a\u306f\u57fa\u672c\u7684\u306a\u95a2\u6570\u306e\u5b9a\u7fa9\u65b9\u6cd5\u3068\u547c\u3073\u51fa\u3057\u65b9\u6cd5\u306b\u3064\u3044\u3066\u89e3\u8aac\u3057\u307e\u3059\u3002<br \/>\n<font color=\"red\" size=\"2em\">2021\/9\/25 \u203b\u3053\u306e\u8a18\u4e8b\u306f\u52a0\u7b46\u3057\u4ee5\u964d\u306e\u30da\u30fc\u30b8\u306b\u5185\u5bb9\u5206\u5272\u3057\u307e\u3057\u305f\u3002<\/font><\/p>\n<h2>\u95a2\u6570\u3068\u306f<\/h2>\n<p>\u3053\u3053\u307e\u3067Python\u306e\u69d8\u3005\u306a\u5909\u6570\u3084\u5236\u5fa1\u6587\u306b\u3064\u3044\u3066\u5b66\u7fd2\u3057\u3066\u304d\u307e\u3057\u305f\u3002\u5909\u6570\u3068\u5236\u5fa1\u6587\u3060\u3051\u3067\u6bd4\u8f03\u7684\u8907\u96d1\u306a\u51e6\u7406\u3092\u4f5c\u6210\u3067\u304d\u308b\u3088\u3046\u306b\u306a\u308b\u306e\u3067\u3059\u304c\u3001\u51e6\u7406\u304c\u5927\u304d\u304f\u306a\u308b\u3068\u69d8\u3005\u306a\u554f\u984c\u304c\u51fa\u3066\u304d\u307e\u3059\u3002<\/p>\n<ul>\n<li>\u540c\u3058\u51e6\u7406\u3092\u4f55\u56de\u3082\u66f8\u304f\u5fc5\u8981\u304c\u3042\u308b<\/li>\n<li>\u51e6\u7406\u306e\u8a18\u8ff0\u304c\u6563\u3089\u3070\u308b<\/li>\n<\/ul>\n<p>\u3053\u3046\u3044\u3063\u305f\u554f\u984c\u306f\u95a2\u6570\u3092\u4f7f\u7528\u3059\u308b\u3053\u3068\u3067\u89e3\u6c7a\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002\u95a2\u6570\u3068\u306f\u51e6\u7406\u3092\u3072\u3068\u3064\u306e\u30d6\u30ed\u30c3\u30af\u306b\u307e\u3068\u3081\u305f\u3082\u306e\u3067\u30011\u56de\u4f5c\u308c\u3070\u4f55\u5ea6\u3082\u540c\u3058\u51e6\u7406\u3092\u547c\u3073\u51fa\u3059\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002\u307e\u305f\u3001\u4e00\u9023\u306e\u51e6\u7406\u3092\u307e\u3068\u307e\u3063\u3066\u8a18\u8ff0\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u308b\u305f\u3081\u53ef\u8aad\u6027\u3092\u5411\u4e0a\u3055\u305b\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002\u95a2\u6570\u306f\u5f15\u6570\u3068\u547c\u3070\u308c\u308b\u5165\u529b\u5024\u306b\u5bfe\u3057\u3066\u51e6\u7406\u3092\u884c\u3044\u3001\u623b\u308a\u5024\u3068\u3044\u3046\u5024\u3092\u547c\u3073\u51fa\u3057\u5143\u306b\u8fd4\u3059\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002<\/p>\n<h2>\u57fa\u672c\u7684\u306a\u95a2\u6570\u306e\u5b9a\u7fa9\u3068\u547c\u3073\u51fa\u3057<\/h2>\n<p>\u305d\u308c\u3067\u306fPython\u306e\u95a2\u6570\u3092\u4f7f\u3063\u3066\u307f\u307e\u3057\u3087\u3046\u3002Python\u306e\u95a2\u6570\u306e\u5b9a\u7fa9\u306fdef\u6587\u3092\u4f7f\u7528\u3057\u307e\u3059\u3002<\/p>\n<div class=\"c_box intitle yellow_box\"><div class=\"box_title\"><span>\u95a2\u6570\u5b9a\u7fa9<\/span><\/div>\ndef \u95a2\u6570\u540d(\u5f15\u6570):<br \/>\n&nbsp;&nbsp;&nbsp;&nbsp;\u51e6\u7406<br \/>\n&nbsp;&nbsp;&nbsp;&nbsp;return \u623b\u308a\u5024<br \/>\n<\/div>\n<p>def\u6587\u306e\u5f8c\u308d\u306b\u95a2\u6570\u540d\u3092\u8a18\u8ff0\u3057\u3001\u5fc5\u8981\u3067\u3042\u308c\u3070\u5f15\u6570\u3092\u8a18\u8ff0\u3057\u307e\u3059\u3002def\u6587\u306e\u6b21\u306e\u884c\u304b\u3089\u30a4\u30f3\u30c7\u30f3\u30c8\u3092\u3064\u3051\u3066\u30d6\u30ed\u30c3\u30af\u5185\u306b\u51e6\u7406\u5185\u5bb9\u3092\u8a18\u8ff0\u3057\u307e\u3059\u3002\u623b\u308a\u5024\u304c\u5fc5\u8981\u3067\u3042\u308b\u5834\u5408\u306freturn\u3092\u8a18\u8ff0\u3057\u307e\u3059\u3002Python\u306e\u5f15\u6570\u306e\u8a18\u6cd5\u306f\u69d8\u3005\u3042\u308b\u306e\u3067\u3001\u6b21\u56de\u4ee5\u964d\u8a73\u3057\u304f\u89e3\u8aac\u3057\u307e\u3059\u3002<\/p>\n<p>\u305d\u308c\u3067\u306f\u5b9f\u969b\u306b\u95a2\u6570\u3092\u4f5c\u6210\u3057\u3066\u307f\u307e\u3057\u3087\u3046\u3002\u4ee5\u4e0b\u306e\u30b5\u30f3\u30d7\u30eb\u306f2\u6570\u306e\u548c\u3092\u8a08\u7b97\u3057\u3066\u8fd4\u3059\u95a2\u6570\u3067\u3059\u3002<\/p>\n<pre class=\"brush: python; title: ; notranslate\" title=\"\">\r\ndef sample_function(x, y):\r\n    z = x + y\r\n    return z\r\n<\/pre>\n<p>\u307e\u305f\u3001\u4f5c\u3063\u305f\u95a2\u6570\u3092\u547c\u3073\u51fa\u3059\u5834\u5408\u306f\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u8a18\u8ff0\u3057\u307e\u3059\u3002<\/p>\n<div class=\"c_box intitle yellow_box\"><div class=\"box_title\"><span>\u95a2\u6570\u306e\u547c\u3073\u51fa\u3057<\/span><\/div>\n\u623b\u308a\u5024\u3092\u683c\u7d0d\u3059\u308b\u5909\u6570 = \u95a2\u6570\u540d(\u5f15\u6570)<br \/>\n<\/div>\n<p>\u3067\u306f\u3001\u5148\u7a0b\u4f5c\u6210\u3057\u305f\u95a2\u6570\u3092\u4f7f\u3063\u3066\u307f\u307e\u3057\u3087\u3046\u3002\u4ee5\u4e0b\u306e\u30b5\u30f3\u30d7\u30eb\u3067\u306f5\u884c\u76ee\u3067\u5f15\u6570\u306b1,2\u3092\u6307\u5b9a\u3057\u3066sample_function\u3092\u547c\u3073\u51fa\u3057\u3066\u3044\u307e\u3059\u3002\u307e\u305f\u3001\u8a08\u7b97\u7d50\u679c\u3067\u3042\u308b\u623b\u308a\u5024\u3092\u5909\u6570z\u306b\u683c\u7d0d\u3057\u3066\u3044\u307e\u3059\u3002<\/p>\n<pre class=\"brush: python; title: ; notranslate\" title=\"\">\r\ndef sample_function(x, y):\r\n    z = x + y\r\n    return z\r\n\r\nz = sample_function(1, 2)\r\nprint(z)\r\n<\/pre>\n<p>\u306a\u304a\u3001return\u306e\u306a\u3044\u95a2\u6570\u306f\u623b\u308a\u5024\u306bNone\u304c\u8a2d\u5b9a\u3055\u308c\u307e\u3059\u3002\u4ee5\u4e0b\u306e\u95a2\u6570\u306f\u623b\u308a\u5024\u304c\u306a\u304f\u3001None\u304c\u8fd4\u3055\u308cz\u306b\u683c\u7d0d\u3055\u308c\u308b\u3053\u3068\u304c\u78ba\u8a8d\u3067\u304d\u307e\u3059\u3002<\/p>\n<pre class=\"brush: python; title: ; notranslate\" title=\"\">\r\ndef sample_function(x, y):\r\n    print(x + y)\r\n\r\nz = sample_function(1, 2)\r\nprint(z)    # None\r\n\r\n<\/pre>\n<h2>\u4f55\u3082\u3057\u306a\u3044\u95a2\u6570<\/h2>\n<p>\u30c6\u30b9\u30c8\u7b49\u3067\u51e6\u7406\u306e\u8a18\u8ff0\u304c\u306a\u3044\u95a2\u6570\u3092\u5b9a\u7fa9\u3057\u305f\u3044\u5834\u5408\u304c\u3042\u308a\u307e\u3059\u304c\u3001\u305d\u306e\u5834\u5408\u306f\u5236\u5fa1\u6587\u3067\u5b66\u7fd2\u3057\u305fpass\u3092\u4f7f\u7528\u3057\u307e\u3059\u3002<\/p>\n<pre class=\"brush: python; title: ; notranslate\" title=\"\">\r\ndef sample_function(x, y):\r\n    # \u51e6\u7406\u306a\u3057\r\n    pass\r\n<\/pre>\n<h2>\u95a2\u6570\u547c\u3073\u51fa\u3057\u306e\u6ce8\u610f\u70b9<\/h2>\n<p>\u5358\u4e00\u306e\u30b9\u30af\u30ea\u30d7\u30c8\u306e\u5834\u5408\u3001\u4e0a\u304b\u3089\u51e6\u7406\u304c\u5b9f\u884c\u3055\u308c\u308b\u305f\u3081\u3001\u95a2\u6570\u3092\u547c\u3073\u51fa\u3059\u51e6\u7406\u306f\u3001\u95a2\u6570\u306e\u5f8c\u306b\u8a18\u8ff0\u3057\u3066\u304f\u3060\u3055\u3044\u3002\u4f8b\u3048\u3070\u3001\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u95a2\u6570\u306e\u8a18\u8ff0\u306e\u524d\u306b\u547c\u3073\u51fa\u3057\u51e6\u7406\u3092\u5b9f\u884c\u3059\u308b\u3068\u3001NameError\u304c\u767a\u751f\u3057\u307e\u3059\u3002<\/p>\n<pre class=\"brush: python; title: ; notranslate\" title=\"\">\r\nz = sample_function(1, 2)\r\nprint(z)\r\n\r\ndef sample_function(x, y):\r\n    z = x + y\r\n    return z\r\n\r\n<\/pre>\n<p>\u5b9f\u884c\u3059\u308b\u3068\u3001\u4ee5\u4e0b\u306e\u30a8\u30e9\u30fc\u304c\u767a\u751f\u3057\u307e\u3059\u3002<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\n$ python sample.py\r\nTraceback (most recent call last):\r\n  File &quot;sample.py&quot;, line 2, in &lt;module&gt;\r\n    z = sample_function(1, 2)\r\nNameError: name 'sample_function' is not defined\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>\u3053\u3053\u304b\u3089\u95a2\u6570\u306b\u3064\u3044\u3066\u89e3\u8aac\u3057\u307e\u3059\u3002Python\u306e\u95a2\u6570\u306e\u8a18\u8ff0\u65b9\u6cd5\u306f\u67d4\u8edf\u3067\u69d8\u3005\u306a\u306e\u3067\u3059\u304c\u3001\u9806\u3092\u8ffd\u3063\u3066\u89e3\u8aac\u3057\u307e\u3059\u3002\u307e\u305a\u306f\u57fa\u672c\u7684\u306a\u95a2\u6570\u306e\u5b9a\u7fa9\u65b9\u6cd5\u3068\u547c\u3073\u51fa\u3057\u65b9\u6cd5\u306b\u3064\u3044\u3066\u89e3\u8aac\u3057\u307e\u3059\u3002 2021\/9\/25 \u203b\u3053\u306e\u8a18\u4e8b\u306f\u52a0\u7b46\u3057\u4ee5\u964d\u306e\u30da\u30fc\u30b8...<\/p>\n","protected":false},"author":1,"featured_media":3461,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[2],"tags":[210],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/www.python.ambitious-engineer.com\/wp-json\/wp\/v2\/posts\/251"}],"collection":[{"href":"https:\/\/www.python.ambitious-engineer.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.python.ambitious-engineer.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.python.ambitious-engineer.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.python.ambitious-engineer.com\/wp-json\/wp\/v2\/comments?post=251"}],"version-history":[{"count":16,"href":"https:\/\/www.python.ambitious-engineer.com\/wp-json\/wp\/v2\/posts\/251\/revisions"}],"predecessor-version":[{"id":3472,"href":"https:\/\/www.python.ambitious-engineer.com\/wp-json\/wp\/v2\/posts\/251\/revisions\/3472"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.python.ambitious-engineer.com\/wp-json\/wp\/v2\/media\/3461"}],"wp:attachment":[{"href":"https:\/\/www.python.ambitious-engineer.com\/wp-json\/wp\/v2\/media?parent=251"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.python.ambitious-engineer.com\/wp-json\/wp\/v2\/categories?post=251"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.python.ambitious-engineer.com\/wp-json\/wp\/v2\/tags?post=251"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}