{"id":198,"date":"2017-01-19T14:16:16","date_gmt":"2017-01-19T05:16:16","guid":{"rendered":"http:\/\/www.python.ambitious-engineer.com\/?p=198"},"modified":"2020-04-27T21:50:46","modified_gmt":"2020-04-27T12:50:46","slug":"range%e5%9e%8b","status":"publish","type":"post","link":"https:\/\/www.python.ambitious-engineer.com\/archives\/198","title":{"rendered":"range\u578b"},"content":{"rendered":"<p>\u4eca\u56de\u306frange\u578b\u306b\u3064\u3044\u3066\u89e3\u8aac\u3057\u307e\u3059\u3002range\u578b\u306f\u300c\u4f55\u306b\u4f7f\u3046\u306e\u304b\u308f\u304b\u3089\u306a\u3044\u300d\u300c\u521d\u671f\u5316\u65b9\u6cd5\u304c\u96e3\u3057\u3044\u300d\u7b49\u3001\u521d\u5fc3\u8005\u6ce3\u304b\u305b\u306a\u5909\u6570\u306a\u306e\u3067\u3059\u304c\u5236\u5fa1\u6587\u7b49\u3067\u5927\u6d3b\u8e8d\u3059\u308b\u91cd\u8981\u306a\u578b\u3067\u3059\u3002\u4e00\u65e6\u3055\u3089\u308a\u3068\u8aad\u307f\u98db\u3070\u3057\u3066\u623b\u3063\u3066\u518d\u5ea6\u5b66\u7fd2\u3059\u308b\u306e\u3082\u4e00\u3064\u306e\u624b\u3060\u3068\u601d\u3044\u307e\u3059\u3002<\/p>\n<h2>range\u578b\u3068\u306f<\/h2>\n<p>range\u578b\u3068\u306f\u6574\u6570\u3092\u8981\u7d20\u3068\u3059\u308b\u30a4\u30df\u30e5\u30fc\u30bf\u30d6\u30eb\u306a\u30b7\u30fc\u30b1\u30f3\u30b9\u3092\u4f5c\u6210\u3059\u308b\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u3067\u3001\u7d44\u307f\u8fbc\u307f\u95a2\u6570\u306erange\u3092\u4f7f\u7528\u3057\u3066\u751f\u6210\u3057\u307e\u3059\u3002\u6574\u6570\u5217\u306e\u30bf\u30d7\u30eb\u306e\u3088\u3046\u306a\u3082\u306e\u306a\u306e\u3067\u3059\u304c\u3001\u521d\u671f\u5316\u306e\u65b9\u6cd5\u306b\u5927\u304d\u306a\u7279\u5fb4\u304c\u3042\u308a\u307e\u3059\u3002\u521d\u671f\u5316\u306e\u969b\u306b\u30b7\u30fc\u30b1\u30f3\u30b9\u306e\u30b5\u30a4\u30ba\u3084\u3001\u5024\u306e\u7bc4\u56f2\u3001\u30b9\u30ad\u30c3\u30d7\u7b49\u3092\u6307\u5b9a\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002\u4ee5\u4e0b\u3001\u5177\u4f53\u7684\u306b\u4f7f\u3063\u3066\u307f\u308b\u3053\u3068\u3067\u7406\u89e3\u3067\u304d\u308b\u3053\u3068\u3068\u601d\u3044\u307e\u3059\u3002<\/p>\n<h2>range\u578b\u306e\u521d\u671f\u5316<\/h2>\n<h3>\u307e\u305a\u4f7f\u3063\u3066\u307f\u308b<\/h3>\n<p>\u307e\u305a\u3001\u6b63\u78ba\u306a\u521d\u671f\u5316\u306e\u69cb\u6587\u306b\u3064\u3044\u3066\u5b66\u7fd2\u3059\u308b\u524d\u306b\u3001\u3068\u308a\u3042\u3048\u305a\u4f7f\u3063\u3066\u307f\u307e\u3057\u3087\u3046\u3002<\/p>\n<pre class=\"brush: python; title: ; notranslate\" title=\"\">\r\nrng = range(5)\r\nprint(rng) # range(0, 5) \u4e2d\u8eab\u306f\u4e00\u4f53\u30fb\u30fb\u30fb\uff1f\r\nprint(list(rng)) # [0, 1, 2, 3, 4]\r\n<\/pre>\n<p>1\u884c\u76ee\u3067range\u578b\u3092\u751f\u6210\u3057\u3066\u3044\u307e\u3059\u3002range(5)\u3068\u8a18\u8ff0\u3059\u308b\u3053\u3068\u3067\u3001\u3053\u308c\u306f\u30010\u304b\u30895\u672a\u6e80\u307e\u3067\u306e\u6574\u6570\u304c\u683c\u7d0d\u3055\u308c\u305f\u30b7\u30fc\u30b1\u30f3\u30b9\u304c\u751f\u6210\u3055\u308c\u307e\u3059\u30022\u884c\u76ee\u3067\u751f\u6210\u3057\u305f\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u3092print\u3067\u53c2\u7167\u3057\u3066\u3044\u307e\u3059\u304c\u3001\u305d\u306e\u307e\u307e\u3060\u3068range(0, 5)\u3068\u8868\u793a\u3055\u308c\u3066\u5185\u5bb9\u304c\u3088\u304f\u308f\u304b\u308a\u307e\u305b\u3093\u3002\u3053\u306e\u305f\u3081\u30013\u884c\u76ee\u3067list\u578b\u306b\u5909\u63db\u3057\u3066\u5185\u5bb9\u3092\u78ba\u8a8d\u3057\u3066\u3044\u307e\u3059\u3002<strong>list\u95a2\u6570\u306e\u5f15\u6570\u306brange\u578b\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u3092\u6307\u5b9a\u3059\u308b\u3068\u3001range\u578b\u304b\u3089list\u578b\u306b\u5909\u63db\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059<\/strong>\u306e\u3067\u305d\u308c\u3092\u5229\u7528\u3057\u3066\u3044\u308b\u308f\u3051\u3067\u3059\u3002range\u578b\u306e\u5185\u5bb9\u3092\u78ba\u8a8d\u3059\u308b\u969b\u306b\u3088\u304f\u4f7f\u7528\u3059\u308b\u30c6\u30af\u30cb\u30c3\u30af\u3067\u3059\u3002range\u578b\u306b\u306a\u308c\u308b\u307e\u3067\u306flist\u306b\u5909\u63db\u3057\u3066\u4e2d\u8eab\u3092\u78ba\u8a8d\u3057\u3066\u307f\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n<h3>\u521d\u671f\u5316\u306e\u69cb\u6587<\/h3>\n<p>range\u578b\u306f\u7d44\u307f\u8fbc\u307f\u95a2\u6570\u306erange\u95a2\u6570\u3092\u4f7f\u7528\u3057\u751f\u6210\u3057\u307e\u3059\u3002\u521d\u671f\u5316\u6642\u306b\u3055\u307e\u3056\u307e\u306a\u6761\u4ef6\u3092\u5f15\u6570\u3067\u6307\u5b9a\u3059\u308b\u3053\u3068\u304c\u53ef\u80fd\u3067\u3059\u3002\u6b63\u78ba\u306b\u306f\u4ee5\u4e0b\u306e\u69cb\u6587\u3067\u7bc4\u56f2\u3084\u30a4\u30f3\u30af\u30ea\u30e1\u30f3\u30c8\u3092\u5909\u3048\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002<\/p>\n<div class=\"c_box intitle yellow_box\"><div class=\"box_title\"><span>\u521d\u671f\u5316<\/span><\/div>\nrange(stop)<br \/>\nrange(start, stop[, step])<br \/>\n<\/div>\n<p>start\u3068stop\u3067\u6307\u5b9a\u3055\u308c\u305f\u533a\u9593\u306e\u30b7\u30fc\u30b1\u30f3\u30b9\u304c\u4f5c\u6210\u3055\u308c\u307e\u3059\u3002step\u3067\u8981\u7d20\u9593\u306e\u5dee\u3092\u6307\u5b9a\u3057\u307e\u3059\u3002step\u5f15\u6570\u306f\u7701\u7565\u304c\u53ef\u80fd\u3067\u3001\u305d\u306e\u5834\u5408\u306f\u30c7\u30d5\u30a9\u30eb\u30c8\u5024\u3068\u3057\u30661\u304c\u8a2d\u5b9a\u3055\u308c\u307e\u3059\u3002\u307e\u305f\u3001\u30de\u30a4\u30ca\u30b9\u306e\u5024\u3092\u6307\u5b9a\u3059\u308b\u3053\u3068\u3082\u53ef\u80fd\u3067\u3059\u3002\u6700\u521d\u306e\u4f8b\u306e\u3088\u3046\u306b\u5f15\u6570\u306bstop\u306e\u307f\u3092\u6307\u5b9a\u3059\u308b\u3053\u3068\u3082\u53ef\u80fd\u3067\u305d\u306e\u5834\u5408\u306f0\u59cb\u307e\u308a\u306erange\u3068\u306a\u308a\u307e\u3059\u3002<\/p>\n<p>\u305d\u308c\u3067\u306f\u3053\u3053\u304b\u3089\u3055\u3089\u306b\u30b5\u30f3\u30d7\u30eb\u3092\u78ba\u8a8d\u3057\u3066\u307f\u307e\u3057\u3087\u3046\u3002\u30b5\u30f3\u30d7\u30eb\u3067\u306f\u5148\u7a0b\u3068\u540c\u69d8\u3001range\u306e\u4e2d\u3092\u78ba\u8a8d\u3059\u308b\u305f\u3081\u306b\u4e00\u65e6\u30ea\u30b9\u30c8\u306b\u5909\u63db\u3057\u3066\u304b\u3089print\u3067\u51fa\u529b\u3057\u3066\u3044\u307e\u3059\u3002<\/p>\n<pre class=\"brush: python; title: ; notranslate\" title=\"\">\r\nr1 = range(5)\r\nprint(list(r1)) # [0, 1, 2, 3, 4]\r\n\r\nr2 = range(1, 5)\r\nprint(list(r2)) # [1, 2, 3, 4]\r\n\r\nr3 = range(1, 5, 2)\r\nprint(list(r3)) # [1, 3]\r\n\r\n<\/pre>\n<p>r1\u306f\u30010\u304b\u30895\u500b\u306e\u6574\u6570\u30b7\u30fc\u30b1\u30f3\u30b9\u304c\u751f\u6210\u3055\u308c\u3066\u3044\u307e\u3059\u30021\u3065\u3064\u5927\u304d\u304f\u306a\u3063\u3066\u3044\u307e\u3059\u3002<br \/>\nr2\u306f\u30011\u304b\u30895\u500b\u306e\u6574\u6570\u30b7\u30fc\u30b1\u30f3\u30b9\u304c\u751f\u6210\u3055\u308c\u3066\u3044\u307e\u3059\u30021\u3065\u3064\u5927\u304d\u304f\u306a\u3063\u3066\u3044\u307e\u3059\u3002<br \/>\nr3\u306f\u30011\u304b\u30895\u500b\u306e\u6574\u6570\u30b7\u30fc\u30b1\u30f3\u30b9\u304c\u751f\u6210\u3055\u308c\u3066\u3044\u307e\u3059\u30022\u3065\u3064\u5927\u304d\u304f\u306a\u3063\u3066\u3044\u307e\u3059\u3002<\/p>\n<h2>for\u6587\u3067\u306e\u5229\u7528<\/h2>\n<p>range\u306e\u4f7f\u3044\u9053\u3067\u3059\u304c\u3001\u6700\u521d\u306flist\u306e\u521d\u671f\u5316\u3068\u30eb\u30fc\u30d7\u3067\u5229\u7528\u3059\u308b\u3053\u3068\u304c\u591a\u3044\u304b\u3068\u601d\u3044\u307e\u3059\u3002Python\u3067\u306fC\u8a00\u8a9e\u3084Java\u306e\u3088\u3046\u306b\u30eb\u30fc\u30d7\u30ab\u30a6\u30f3\u30bf\u3092\u6307\u5b9a\u3057\u305ffor\u6587\u304c\u306a\u3044\u305f\u3081\u3001\u540c\u3058\u3088\u3046\u306a\u66f8\u304d\u65b9\u3092\u3057\u305f\u3044\u5834\u5408\u306frange\u3092\u5229\u7528\u3057\u307e\u3059\u3002\uff08for\u6587\u306b\u3064\u3044\u3066\u306f<a href=\"http:\/\/www.python.ambitious-engineer.com\/archives\/233\">\u3053\u3061\u3089<\/a>\u3067\u8aac\u660e\u3057\u307e\u3059\u3002\uff09<\/p>\n<p>java\u3067\u30ab\u30a6\u30f3\u30bf\u3092\u6307\u5b9a\u3057\u305ffor\u6587\u3092\u4f7f\u7528\u3059\u308b\u5834\u5408\u3001\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u8a18\u8ff0\u3057\u307e\u3059\u3002<\/p>\n<pre class=\"brush: java; title: ; notranslate\" title=\"\">\r\n\/\/ java\u306efor\u6587\r\nfor(i = 0; i &lt; 10; i++){\r\n    \/\/ \u51e6\u7406\r\n<\/pre>\n<p>\u3053\u308c\u3092Python\u306b\u66f8\u304d\u76f4\u3059\u3068\u3001\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n<pre class=\"brush: python; title: ; notranslate\" title=\"\">\r\n# Python\u306e\u5834\u5408\r\nfor i in range(0, 10):\r\n    # \u51e6\u7406\r\n<\/pre>\n<p>\u3082\u3063\u3068\u3082\u3001Python\u3067\u306flist\u306e\u3088\u3046\u306a\u30a4\u30c6\u30e9\u30d6\u30eb\u306a\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u306b\u3064\u3044\u3066\u306f\u30ab\u30a6\u30f3\u30bf\u3092\u8003\u616e\u305b\u305a\u306bfor\u6587\u3092\u4f7f\u7528\u3067\u304d\u308b\u306e\u3067\u3001\u4e0a\u306e\u3088\u3046\u306a\u30eb\u30fc\u30d7\u306f\u3042\u307e\u308a\u4f7f\u7528\u3055\u308c\u307e\u305b\u3093\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u4eca\u56de\u306frange\u578b\u306b\u3064\u3044\u3066\u89e3\u8aac\u3057\u307e\u3059\u3002range\u578b\u306f\u300c\u4f55\u306b\u4f7f\u3046\u306e\u304b\u308f\u304b\u3089\u306a\u3044\u300d\u300c\u521d\u671f\u5316\u65b9\u6cd5\u304c\u96e3\u3057\u3044\u300d\u7b49\u3001\u521d\u5fc3\u8005\u6ce3\u304b\u305b\u306a\u5909\u6570\u306a\u306e\u3067\u3059\u304c\u5236\u5fa1\u6587\u7b49\u3067\u5927\u6d3b\u8e8d\u3059\u308b\u91cd\u8981\u306a\u578b\u3067\u3059\u3002\u4e00\u65e6\u3055\u3089\u308a\u3068\u8aad\u307f\u98db\u3070\u3057\u3066\u623b\u3063\u3066\u518d\u5ea6\u5b66\u7fd2\u3059\u308b\u306e\u3082\u4e00\u3064\u306e\u624b...<\/p>\n","protected":false},"author":1,"featured_media":3407,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[2],"tags":[48,136],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/www.python.ambitious-engineer.com\/wp-json\/wp\/v2\/posts\/198"}],"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=198"}],"version-history":[{"count":13,"href":"https:\/\/www.python.ambitious-engineer.com\/wp-json\/wp\/v2\/posts\/198\/revisions"}],"predecessor-version":[{"id":3715,"href":"https:\/\/www.python.ambitious-engineer.com\/wp-json\/wp\/v2\/posts\/198\/revisions\/3715"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.python.ambitious-engineer.com\/wp-json\/wp\/v2\/media\/3407"}],"wp:attachment":[{"href":"https:\/\/www.python.ambitious-engineer.com\/wp-json\/wp\/v2\/media?parent=198"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.python.ambitious-engineer.com\/wp-json\/wp\/v2\/categories?post=198"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.python.ambitious-engineer.com\/wp-json\/wp\/v2\/tags?post=198"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}