{"id":260,"date":"2017-02-04T23:20:35","date_gmt":"2017-02-04T14:20:35","guid":{"rendered":"http:\/\/www.python.ambitious-engineer.com\/?p=260"},"modified":"2021-09-26T18:19:47","modified_gmt":"2021-09-26T09:19:47","slug":"blobal%e5%ae%a3%e8%a8%80","status":"publish","type":"post","link":"https:\/\/www.python.ambitious-engineer.com\/archives\/260","title":{"rendered":"global\u5ba3\u8a00"},"content":{"rendered":"<h2>\u30ed\u30fc\u30ab\u30eb\u5909\u6570\u3068\u30b0\u30ed\u30fc\u30d0\u30eb\u5909\u6570<\/h2>\n<p>\u3053\u308c\u307e\u3067\u4f7f\u7528\u3057\u305fPython\u306e\u5909\u6570\u306e\u5ba3\u8a00\u7b87\u6240\u306f\u5927\u5225\u3059\u308b\u3068\u4ee5\u4e0b\u306e\u901a\u308a\u95a2\u6570\u5185\u5916\u306e2\u901a\u308a\u304c\u3042\u308a\u307e\u3059\u3002<\/p>\n<ul>\n<li>\u95a2\u6570\u306e\u5916\u5074<\/li>\n<li>\u95a2\u6570\u306e\u5185\u5074<\/li>\n<\/ul>\n<pre class=\"brush: python; title: ; notranslate\" title=\"\">\r\nx = 100\r\n\r\ndef func():\r\n    y = &quot;sample&quot;\r\n    print(y)\r\n\r\n<\/pre>\n<p>\u4e0a\u306e\u4f8b\u3067\u3044\u3046\u3068x\u306f\u95a2\u6570\u306e\u5916\u5074\u3001y\u306f\u95a2\u6570\u306e\u5185\u5074\u3067\u5b9a\u7fa9\u3055\u308c\u3066\u3044\u307e\u3059\u3002\u95a2\u6570\u306e\u5916\u5074\u3067\u5b9a\u7fa9\u3057\u305f\u5909\u6570\u3092\u30e2\u30b8\u30e5\u30fc\u30eb\u5909\u6570\u82e5\u3057\u304f\u306f\u30b0\u30ed\u30fc\u30d0\u30eb\u5909\u6570\u3068\u547c\u3073\u307e\u3059\u3002\uff08\u300c\u30b0\u30ed\u30fc\u30d0\u30eb\u5909\u6570\u300d\u3068\u3044\u3046\u540d\u79f0\u306b\u306f\u8b70\u8ad6\u304c\u3042\u308b\u306e\u3067\u3059\u304c\u3001\u672c\u7a3f\u3067\u306f\u4ee5\u964d\u30b0\u30ed\u30fc\u30d0\u30eb\u5909\u6570\u3068\u3044\u3046\u7528\u8a9e\u3092\u4f7f\u7528\u3057\u307e\u3059\u3002\uff09\u4e00\u65b9\u3001\u95a2\u6570\u306e\u5185\u5074\u3067\u5b9a\u7fa9\u3057\u305f\u5909\u6570\u3092\u30ed\u30fc\u30ab\u30eb\u5909\u6570\u3068\u547c\u3073\u307e\u3059\u3002\u30ed\u30fc\u30ab\u30eb\u5909\u6570\u306f\u95a2\u6570\u5185\u90e8\u3067\u306e\u307f\u6709\u52b9\u3068\u306a\u308a\u307e\u3059\u3002\u3064\u307e\u308a\u3001\u3042\u308b\u95a2\u6570\u304b\u3089\u5225\u306e\u95a2\u6570\u306e\u30ed\u30fc\u30ab\u30eb\u5909\u6570\u306f\u53c2\u7167\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u305b\u3093\u3002\u4e00\u65b9\u3067\u3001\u30b0\u30ed\u30fc\u30d0\u30eb\u5909\u6570\u306f\u4ed6\u306e\u95a2\u6570\u304b\u3089\u3082\u53c2\u7167\u3057\u305f\u308a\u66f4\u65b0\u3059\u308b\u3053\u3068\u304c\u53ef\u80fd\u3067\u3059\u3002<\/p>\n<h3>\u30b0\u30ed\u30fc\u30d0\u30eb\u5909\u6570\u306e\u53c2\u7167<\/h3>\n<p>\u95a2\u6570\u306e\u5185\u90e8\u304b\u3089\u30b0\u30ed\u30fc\u30d0\u30eb\u5909\u6570\u306e\u5024\u3092\u8aad\u307f\u53d6\u308b\u5834\u5408\u3001\u7279\u306b\u4f55\u304b\u3092\u305b\u305a\u53ef\u80fd\u3067\u3059\u3002\u4ee5\u4e0b\u306e\u30b5\u30f3\u30d7\u30eb\u3067\u306f\u30b0\u30ed\u30fc\u30d0\u30eb\u5909\u6570x\u3092\u95a2\u6570sample_function\u5185\u90e8\u3067\u8aad\u307f\u53d6\u3063\u3066\u3044\u307e\u3059\u3002<\/p>\n<pre class=\"brush: python; title: ; notranslate\" title=\"\">\r\nx = 100\r\ndef sample_function():\r\n    print(x) # 100\u304c\u51fa\u529b\u3055\u308c\u308b\r\n\r\nsample_function()\r\n<\/pre>\n<p>\u5b9f\u884c\u3059\u308b\u3068\u5909\u6570x\u306e\u5024\u304c\u51fa\u529b\u3055\u308c\u308b\u3053\u3068\u304c\u78ba\u8a8d\u3067\u304d\u307e\u3059\u3002<\/p>\n<h3>\u30b0\u30ed\u30fc\u30d0\u30eb\u5909\u6570\u306e\u66f4\u65b0<\/h3>\n<p>\u307e\u305f\u3001\u95a2\u6570\u306e\u5185\u90e8\u3067\u30b0\u30ed\u30fc\u30d0\u30eb\u5909\u6570\u306b\u4ee3\u5165\u3057\u305f\u5834\u5408\u3001\u30ed\u30fc\u30ab\u30eb\u5909\u6570\u306e\u5b9a\u7fa9\u3068\u3057\u3066\u6271\u308f\u308c\u3066\u3057\u307e\u3044\u307e\u3059\u3002\u3053\u306e\u5834\u5408\u3001\u30b0\u30ed\u30fc\u30d0\u30eb\u5909\u6570\u306f\u5909\u66f4\u3055\u308c\u307e\u305b\u3093\u3002<\/p>\n<pre class=\"brush: python; title: ; notranslate\" title=\"\">\r\nx = 100\r\ndef sample_function():\r\n    x = 200\r\n    print(x) # 200\u304c\u51fa\u529b\u3055\u308c\u308b\r\n\r\nsample_function() # \u95a2\u6570\u5185\u90e8\u3067x\u306e\u5024\u3092\u5909\u66f4\r\nprint(x) # 100\u304c\u51fa\u529b\u3055\u308c\u308b\u3002\u3064\u307e\u308a\u3001\u95a2\u6570\u306e\u5916\u5074\u306e\u5024\u306f\u5909\u66f4\u3055\u308c\u306a\u3044\r\n<\/pre>\n<p>\u4e0a\u306e\u30b5\u30f3\u30d7\u30eb\u3092\u5b9f\u884c\u3059\u308b\u3068\u3001\u4ee3\u5165\u3059\u308b\u3068\u65b0\u305f\u306a\u30ed\u30fc\u30ab\u30eb\u5909\u6570\u304c\u751f\u6210\u3055\u308c\u3001\u30b0\u30ed\u30fc\u30d0\u30eb\u5909\u6570\u306b\u4ee3\u5165\u3067\u304d\u306a\u3044\u3053\u3068\u304c\u78ba\u8a8d\u3067\u304d\u307e\u3059\u3002\u3067\u306f\u3001\u30b0\u30ed\u30fc\u30d0\u30eb\u5909\u6570\u3092\u66f4\u65b0\u3059\u308b\u5834\u5408\u306f\u3069\u3046\u3059\u308c\u3070\u3088\u3044\u3067\u3057\u3087\u3046\u304b\uff1f\u3053\u308c\u306f\u3001global\u5ba3\u8a00\u3092\u8a18\u8ff0\u3059\u308b\u3053\u3068\u3067\u89e3\u6c7a\u3057\u307e\u3059\u3002<\/p>\n<pre class=\"brush: python; title: ; notranslate\" title=\"\">\r\nx = 100\r\ndef sample_function():\r\n    global x # global\u5ba3\u8a00 x\u306fglobal\u5909\u6570\u3067\u3042\u308b\u3053\u3068\u3092\u660e\u793a\u3059\u308b\r\n    x = 200\r\n    print(x)\r\n\r\nsample_function() # \u95a2\u6570\u5185\u90e8\u3067x\u306e\u5024\u3092\u5909\u66f4\r\nprint(x) # \u95a2\u6570\u306e\u5916\u5074\u306e\u5024\u304c\u5909\u66f4\u3055\u308c\u3066\u3044\u308b\r\n<\/pre>\n<p>\u4e0a\u306e\u30b5\u30f3\u30d7\u30eb\u3067\u306f\u30b0\u30ed\u30fc\u30d0\u30eb\u5909\u6570\u304c\u66f4\u65b0\u3055\u308c\u3066\u3044\u308b\u3053\u3068\u304c\u78ba\u8a8d\u3067\u304d\u307e\u3059\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u30ed\u30fc\u30ab\u30eb\u5909\u6570\u3068\u30b0\u30ed\u30fc\u30d0\u30eb\u5909\u6570 \u3053\u308c\u307e\u3067\u4f7f\u7528\u3057\u305fPython\u306e\u5909\u6570\u306e\u5ba3\u8a00\u7b87\u6240\u306f\u5927\u5225\u3059\u308b\u3068\u4ee5\u4e0b\u306e\u901a\u308a\u95a2\u6570\u5185\u5916\u306e2\u901a\u308a\u304c\u3042\u308a\u307e\u3059\u3002 \u95a2\u6570\u306e\u5916\u5074 \u95a2\u6570\u306e\u5185\u5074 \u4e0a\u306e\u4f8b\u3067\u3044\u3046\u3068x\u306f\u95a2\u6570\u306e\u5916\u5074\u3001y\u306f\u95a2\u6570\u306e\u5185\u5074\u3067\u5b9a\u7fa9\u3055\u308c\u3066\u3044\u307e\u3059\u3002\u95a2\u6570\u306e...<\/p>\n","protected":false},"author":1,"featured_media":3480,"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\/260"}],"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=260"}],"version-history":[{"count":6,"href":"https:\/\/www.python.ambitious-engineer.com\/wp-json\/wp\/v2\/posts\/260\/revisions"}],"predecessor-version":[{"id":3477,"href":"https:\/\/www.python.ambitious-engineer.com\/wp-json\/wp\/v2\/posts\/260\/revisions\/3477"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.python.ambitious-engineer.com\/wp-json\/wp\/v2\/media\/3480"}],"wp:attachment":[{"href":"https:\/\/www.python.ambitious-engineer.com\/wp-json\/wp\/v2\/media?parent=260"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.python.ambitious-engineer.com\/wp-json\/wp\/v2\/categories?post=260"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.python.ambitious-engineer.com\/wp-json\/wp\/v2\/tags?post=260"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}