{"id":168,"date":"2017-01-18T19:14:52","date_gmt":"2017-01-18T10:14:52","guid":{"rendered":"http:\/\/www.python.ambitious-engineer.com\/?p=168"},"modified":"2020-04-27T21:44:37","modified_gmt":"2020-04-27T12:44:37","slug":"%e3%82%bf%e3%83%97%e3%83%abtuple%e5%9e%8b","status":"publish","type":"post","link":"https:\/\/www.python.ambitious-engineer.com\/archives\/168","title":{"rendered":"\u30bf\u30d7\u30eb(tuple)\u578b"},"content":{"rendered":"<p>Python\u306b\u306f\u30b7\u30fc\u30b1\u30f3\u30b9\u306e\u4e00\u7a2e\u3067\u30bf\u30d7\u30eb(tuple)\u578b\u3068\u547c\u3070\u308c\u308b\u578b\u304c\u3042\u308a\u307e\u3059\u3002\u3053\u306e\u30da\u30fc\u30b8\u3067\u306f\u30bf\u30d7\u30eb\u306b\u3064\u3044\u3066\u89e3\u8aac\u3057\u307e\u3059\u3002<\/p>\n<h2>\u30bf\u30d7\u30eb\u3068\u306f<\/h2>\n<p>\u5192\u982d\u3067\u8ff0\u3079\u305f\u3068\u304a\u308a\u3001Python\u306b\u306f\u30bf\u30d7\u30eb(tuple)\u578b\u3068\u3044\u3046\u30b7\u30fc\u30b1\u30f3\u30b9\u306e\u578b\u304c\u3042\u308a\u307e\u3059\u3002\u30ea\u30b9\u30c8\u3068\u540c\u69d8\u306b\u9806\u5e8f\u4ed8\u3051\u3089\u308c\u305f\u8907\u6570\u306e\u5024\u3092\u683c\u7d0d\u3059\u308b\u3053\u3068\u304c\u53ef\u80fd\u3067\u3059\u3002\u30ea\u30b9\u30c8\u3068\u7570\u306a\u308b\u70b9\u306f\u3001\u4e00\u5ea6\u521d\u671f\u5316\u3057\u305f\u30bf\u30d7\u30eb\u306e\u8981\u7d20\u306f\u5909\u66f4\u3067\u304d\u306a\u3044\u3001\u3068\u3044\u3046\u70b9\u3067\u3059\u3002\u3053\u306e\u6027\u8cea\u306e\u3053\u3068\u3092\u30a4\u30df\u30e5\u30fc\u30bf\u30d6\u30eb\uff08\u4e0d\u5909\uff09\u3068\u547c\u3073\u307e\u3059\u3002\u3053\u306e\u305f\u3081\u3001\u8981\u7d20\u3092\u66f4\u65b0\u3001\u524a\u9664\u3057\u305f\u308a\u30bf\u30d7\u30eb\u305d\u306e\u3082\u306e\u306e\u9806\u5e8f\u3092\u30bd\u30fc\u30c8\u3059\u308b\u3088\u3046\u306a\u66f4\u65b0\u7cfb\u306e\u51e6\u7406\u3092\u3059\u308b\u3053\u3068\u306f\u3067\u304d\u307e\u305b\u3093\u3002\uff08\u4ee5\u964d\u3001\u30bf\u30d7\u30eb\u578b\u306e\u5909\u6570\u3092\u5358\u306b\u30bf\u30d7\u30eb\u3068\u8a18\u8ff0\u3059\u308b\u3053\u3068\u304c\u3042\u308a\u307e\u3059\u3002\uff09<\/p>\n<h2>\u30bf\u30d7\u30eb\u306e\u521d\u671f\u5316<\/h2>\n<p>\u30bf\u30d7\u30eb\u306f\u4e38\u62ec\u5f27\u3067\u8981\u7d20\u3092\u30ab\u30f3\u30de\u533a\u5207\u308a\u3067\u5217\u6319\u3057\u3066\u8a18\u8ff0\u3057\u307e\u3059\u3002\u306a\u304a\u3001<strong>\u8981\u7d20\u304c1\u3064\u3057\u304b\u306a\u3044\u5834\u5408\u306f\u5fc5\u305a\u30ab\u30f3\u30de\u3092\u3064\u3051\u306a\u3051\u308c\u3070\u306a\u308a\u307e\u305b\u3093<\/strong>\u3002\u307e\u305f\u3001\u4e38\u62ec\u5f27\u306f\u7701\u7565\u3059\u308b\u3053\u3068\u3082\u53ef\u80fd\u3067\u3059\u3002<\/p>\n<p>\u30b5\u30f3\u30d7\u30eb\u3092\u898b\u3066\u307f\u307e\u3057\u3087\u3046\u3002<\/p>\n<pre class=\"brush: python; title: ; notranslate\" title=\"\">\r\n# \u8981\u7d20\u304c\u306a\u3044\u30bf\u30d7\u30eb\r\nt1 = ()\r\nprint(t1) # ()\r\n\r\n# \u8981\u7d20\u304c\u3072\u3068\u3064\u306e\u5834\u5408\u306f\u30ab\u30f3\u30de\u3092\u3064\u3051\u306a\u3044\u3068\u3001\u5358\u4e00\u306e\u5024\u3068\u307f\u306a\u3055\u308c\u3066\u3057\u307e\u3046\u3002\r\nt2 = (1)\r\nprint(t2) # 1\uff08\u5358\u4e00\u306e\u5024\u6271\u3044\uff09\r\n\r\n# \u8981\u7d20\u304c\u3072\u3068\u3064\u306e\u5834\u5408\u306f\u30ab\u30f3\u30de\u3092\u3064\u3051\u308b\r\nt2 = (1,)\r\nprint(t2) # (1,)\r\n\r\n# \u30ab\u30f3\u30de\u533a\u5207\u308a\u3067\u8907\u6570\u306e\u8981\u7d20\u3092\u30bb\u30c3\u30c8\u3059\u308b\r\nt3 = ('a', 'b', 'c')\r\nprint(t3) # ('a', 'b', 'c')\r\n<\/pre>\n<p>\u307e\u305f\u3001\u672b\u5c3e\u306b\u30ab\u30f3\u30de\u3092\u6b8b\u3057\u3066\u3082\u69cb\u3044\u307e\u305b\u3093\u3002<\/p>\n<pre class=\"brush: python; title: ; notranslate\" title=\"\">\r\nt = (1, 2, 3,)\r\nprint(t) # (1, 2, 3)\r\n<\/pre>\n<h2>\u30bf\u30d7\u30eb\u306e\u8981\u7d20\u6570<\/h2>\n<p>\u30ea\u30b9\u30c8\u3068\u540c\u69d8\u3001len\u95a2\u6570\u3092\u4f7f\u7528\u3059\u308b\u3068\u30bf\u30d7\u30eb\u306e\u8981\u7d20\u6570\u3092\u5f97\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002<\/p>\n<pre class=\"brush: python; title: ; notranslate\" title=\"\">\r\nt = (1, 2, 3,)\r\nl = len(t)\r\nprint(l)    # 3\r\n<\/pre>\n<h2>\u30ea\u30b9\u30c8\u304b\u3089\u30bf\u30d7\u30eb\u3078\u306e\u5909\u63db<\/h2>\n<p>\u30bf\u30d7\u30eb\u306f\u7d44\u307f\u8fbc\u307f\u95a2\u6570\u306etuple()\u3092\u4f7f\u7528\u3057\u3066\u30ea\u30b9\u30c8\u304b\u3089\u751f\u6210\uff08\u5909\u63db\uff09\u3059\u308b\u65b9\u6cd5\u304c\u3042\u308a\u307e\u3059\u3002<\/p>\n<pre class=\"brush: python; title: ; notranslate\" title=\"\">\r\n# \u30ea\u30b9\u30c8\u3092\u521d\u671f\u5316\r\nl = [1, 2, 3]\r\n\r\n# \u30ea\u30b9\u30c8\u304b\u3089\u30bf\u30d7\u30eb\u3092\u521d\u671f\u5316\uff08\u30ea\u30b9\u30c8\u3092\u30bf\u30d7\u30eb\u306b\u5909\u63db\uff09\r\nt = tuple(l)\r\nprint(t) # (1, 2, 3)\r\n\r\n<\/pre>\n<h2>\u30bf\u30d7\u30eb\u304b\u3089\u30ea\u30b9\u30c8\u3078\u306e\u5909\u63db<\/h2>\n<p>\u307e\u305f\u3001\u9006\u306b\u30bf\u30d7\u30eb\u304b\u3089\u30ea\u30b9\u30c8\u3092\u751f\u6210\u3059\u308b\u5834\u5408\u306f<a href=\"http:\/\/www.python.ambitious-engineer.com\/archives\/134\">\u3053\u3061\u3089\u3067<\/a>\u89e6\u308c\u307e\u3057\u305f\u304c\u3001list\u95a2\u6570\u3067\u53ef\u80fd\u3068\u306a\u308a\u307e\u3059\u3002<\/p>\n<pre class=\"brush: python; title: ; notranslate\" title=\"\">\r\nt = (1, 2, 3,)\r\nl = list(t)\r\nprint(l) # [1, 2, 3]\r\n<\/pre>\n<h2>\u30bf\u30d7\u30eb\u306e\u30e1\u30ea\u30c3\u30c8<\/h2>\n<p>\u30ea\u30b9\u30c8\u3068\u6bd4\u8f03\u3059\u308b\u3068\u3001\u66f4\u65b0\u7cfb\u306e\u51e6\u7406\u304c\u3067\u304d\u306a\u3044\u305f\u3081\u4e0d\u4fbf\u306b\u611f\u3058\u308b\u304b\u3082\u3057\u308c\u307e\u305b\u3093\u304c\u3001\u4e00\u5ea6\u78ba\u5b9a\u3057\u305f\u5024\u3092\u9014\u4e2d\u3067\u5909\u3048\u3055\u305b\u306a\u3044\u3067\u5b89\u5168\u306b\u4fdd\u6301\u30fb\u53d7\u3051\u6e21\u3057\u3057\u305f\u3044\u3068\u304d\u306b\u6d3b\u8e8d\u3057\u307e\u3059\u3002\u7279\u306b\u95a2\u6570\u306e\u30b3\u30fc\u30eb\u30b7\u30fc\u30b1\u30f3\u30b9\u304c\u8907\u96d1\u306a\u5834\u5408\u3001\u30ea\u30b9\u30c8\u306e\u3088\u3046\u306b\u9014\u4e2d\u3067\u5909\u66f4\u304c\u5165\u308b\u53ef\u80fd\u6027\u304c\u3042\u308b\u5834\u5408\u3001\u601d\u308f\u306c\u4e0d\u5177\u5408\u304c\u767a\u751f\u3059\u308b\u539f\u56e0\u306b\u306a\u308b\u305f\u3081\u30bf\u30d7\u30eb\u3092\u4f7f\u7528\u3057\u305f\u307b\u3046\u304c\u3088\u308a\u5b89\u5168\u306b\u30b3\u30fc\u30c7\u30a3\u30f3\u30b0\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002<\/p>\n<p>\u307e\u305f\u3001\u30ea\u30b9\u30c8\u3068\u6bd4\u8f03\u3057\u3066\uff08\u5c11\u3057\u3060\u3051\uff09\u51e6\u7406\u3059\u308b\u969b\u306e\u30b9\u30d4\u30fc\u30c9\u304c\u901f\u3044\u3067\u3059\u3002\u307e\u305f\u3001\u30a4\u30df\u30e5\u30fc\u30bf\u30d6\u30eb\u306a\u306e\u3067\u30cf\u30c3\u30b7\u30e5\u5316\u3059\u308b\u3053\u3068\u304c\u53ef\u80fd\u3067\u3042\u308b\u305f\u3081\u3001\u5f8c\u8ff0\u3059\u308b\u8f9e\u66f8\u306e\u30ad\u30fc\u3068\u3057\u3066\u4f7f\u7528\u3059\u308b\u3053\u3068\u304c\u53ef\u80fd\u3067\u3059\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Python\u306b\u306f\u30b7\u30fc\u30b1\u30f3\u30b9\u306e\u4e00\u7a2e\u3067\u30bf\u30d7\u30eb(tuple)\u578b\u3068\u547c\u3070\u308c\u308b\u578b\u304c\u3042\u308a\u307e\u3059\u3002\u3053\u306e\u30da\u30fc\u30b8\u3067\u306f\u30bf\u30d7\u30eb\u306b\u3064\u3044\u3066\u89e3\u8aac\u3057\u307e\u3059\u3002 \u30bf\u30d7\u30eb\u3068\u306f \u5192\u982d\u3067\u8ff0\u3079\u305f\u3068\u304a\u308a\u3001Python\u306b\u306f\u30bf\u30d7\u30eb(tuple)\u578b\u3068\u3044\u3046\u30b7\u30fc\u30b1\u30f3\u30b9\u306e\u578b\u304c\u3042\u308a\u307e...<\/p>\n","protected":false},"author":1,"featured_media":3405,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[2],"tags":[48],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/www.python.ambitious-engineer.com\/wp-json\/wp\/v2\/posts\/168"}],"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=168"}],"version-history":[{"count":3,"href":"https:\/\/www.python.ambitious-engineer.com\/wp-json\/wp\/v2\/posts\/168\/revisions"}],"predecessor-version":[{"id":3406,"href":"https:\/\/www.python.ambitious-engineer.com\/wp-json\/wp\/v2\/posts\/168\/revisions\/3406"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.python.ambitious-engineer.com\/wp-json\/wp\/v2\/media\/3405"}],"wp:attachment":[{"href":"https:\/\/www.python.ambitious-engineer.com\/wp-json\/wp\/v2\/media?parent=168"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.python.ambitious-engineer.com\/wp-json\/wp\/v2\/categories?post=168"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.python.ambitious-engineer.com\/wp-json\/wp\/v2\/tags?post=168"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}