{"id":633,"date":"2017-03-03T00:17:06","date_gmt":"2017-03-02T15:17:06","guid":{"rendered":"http:\/\/www.python.ambitious-engineer.com\/?p=633"},"modified":"2020-05-03T20:47:26","modified_gmt":"2020-05-03T11:47:26","slug":"%e8%be%9e%e6%9b%b8%e5%9e%8b%e3%81%a7%e9%a0%86%e5%ba%8f%e3%82%92%e4%bf%9d%e3%81%a4%e6%96%b9%e6%b3%95-ordereddict","status":"publish","type":"post","link":"https:\/\/www.python.ambitious-engineer.com\/archives\/633","title":{"rendered":"OrderedDict \u8f9e\u66f8\u578b\u3067\u9806\u5e8f\u3092\u4fdd\u3064\u65b9\u6cd5(Python3.5\u4ee5\u524d)"},"content":{"rendered":"<p><font color=\"red\">\u3053\u306e\u8a18\u4e8b\u3092\u66f8\u3044\u305f\u6642\u70b9\u3001Python3.5\u3067\u306f\u8f9e\u66f8\u578b\u306f\u9806\u5e8f\u3092\u4fdd\u305f\u306a\u304b\u3063\u305f\u306e\u3067\u3059\u304c\u3001\u6a19\u6e96Python\uff08CPython\uff09\u3067\u306f3.6\u304b\u3089\u9806\u5e8f\u304c\u4fdd\u305f\u308c\u308b\u3088\u3046\u306b\u306a\u308a\u307e\u3057\u305f\u3002\u307e\u305f\u3001\u305d\u306e\u4ed6\u306e\u5b9f\u88c5\u306ePython\u3067\u30823.7\u4ee5\u964d\u9806\u5e8f\u304c\u4fdd\u305f\u308c\u308b\u3088\u3046\u306b\u306a\u3063\u305f\u305f\u3081\u3001\u6700\u65b0\u7248\u3092\u4f7f\u7528\u3055\u308c\u3066\u3044\u308b\u65b9\u306b\u3068\u3063\u3066\u3053\u306e\u8a18\u4e8b\u306f\u4e0d\u8981\u3067\u3059\u3002<\/font><\/p>\n<p>\u4ee5\u4e0b\u3001\u516c\u5f0f\u304b\u3089\u306e\u5f15\u7528\u3067\u3059\u3002<\/p>\n<div class=\"inyoumodoki\">\nhttps:\/\/docs.python.org\/ja\/3\/library\/stdtypes.html#dict<br \/>\n\u30d0\u30fc\u30b8\u30e7\u30f3 3.7 \u3067\u5909\u66f4: \u8f9e\u66f8\u306e\u9806\u5e8f\u304c\u633f\u5165\u9806\u5e8f\u3067\u3042\u308b\u3053\u3068\u304c\u4fdd\u8a3c\u3055\u308c\u308b\u3088\u3046\u306b\u306a\u308a\u307e\u3057\u305f\u3002\u3053\u306e\u632f\u308b\u821e\u3044\u306f CPython 3.6 \u306e\u5b9f\u88c5\u8a73\u7d30\u3067\u3057\u305f\u3002\n<\/div>\n<h2>dict\u578b\u306f\u9806\u5e8f\u3092\u4fdd\u305f\u306a\u3044<\/h2>\n<p>Python3.5\u4ee5\u524d\u306edict\u578b\u306f\u9806\u5e8f\u3092\u4fdd\u3061\u307e\u305b\u3093\u3002<\/p>\n<pre class=\"brush: python; title: ; notranslate\" title=\"\">\r\ndata_dict = {'apple': 100, 'orange': 80, 'banana': 70}\r\nfor key, val in data_dict.items():\r\n    print(key, val) # \u5b9f\u884c\u3059\u308b\u305f\u3073\u306b\u9806\u5e8f\u304c\u5909\u308f\u308b\r\n<\/pre>\n<p>Python3.5\u3067\u4e0a\u306e\u30b9\u30af\u30ea\u30d7\u30c8\u3092\u4f55\u5ea6\u304b\u5b9f\u884c\u3057\u3066\u307f\u3066\u304f\u3060\u3055\u3044\u3002\u5b9f\u884c\u3059\u308b\u305f\u3073\u306b\u51fa\u529b\u3055\u308c\u308b\u9806\u5e8f\u304c\u5909\u308f\u308b\u3053\u3068\u304c\u78ba\u8a8d\u3067\u304d\u307e\u3059\u3002<\/p>\n<h2>\u9806\u5e8f\u3092\u4fdd\u3064OrderedDict<\/h2>\n<p>\u3055\u3066\u3001python\u6a19\u6e96\u30e9\u30a4\u30d6\u30e9\u30ea\u306ecollections\u30e2\u30b8\u30e5\u30fc\u30eb\u306b\u306fOrderedDict\u3068\u3044\u3046\u9806\u5e8f\u3092\u4fdd\u3064\u8f9e\u66f8\u578b\u304c\u7528\u610f\u3055\u308c\u3066\u3044\u307e\u3059\u3002\u9806\u5e8f\u3092\u4fdd\u3063\u305f\u8f9e\u66f8\u304c\u5fc5\u8981\u306a\u5834\u5408\u306f\u3053\u306e\u578b\u3092\u4f7f\u7528\u3057\u307e\u3057\u3087\u3046\u3002<\/p>\n<pre class=\"brush: python; title: ; notranslate\" title=\"\">\r\nfrom collections import OrderedDict\r\ndata_dict = OrderedDict()\r\ndata_dict['apple'] = 100\r\ndata_dict['orange'] = 80\r\ndata_dict['banana'] = 70\r\n\r\n# \u901a\u5e38\u306e\u8f9e\u66f8\u3068\u540c\u3058\u3088\u3046\u306b\u4f7f\u7528\u3067\u304d\u308b\r\nfor key, val in data_dict.items():\r\n    print(key, val)\r\n<\/pre>\n<p>\u4eca\u5ea6\u306f\u4f55\u5ea6\u5b9f\u884c\u3057\u3066\u3082\u8ffd\u52a0\u3057\u305f\u9806\u756a\u3067\u51fa\u529b\u3055\u308c\u308b\u3053\u3068\u304c\u78ba\u8a8d\u3067\u304d\u305f\u3068\u601d\u3044\u307e\u3059\u3002OrderedDict\u306f\u30ad\u30fc\u304c\u8ffd\u52a0\u3055\u308c\u305f\u9806\u5e8f\u3092\u8a18\u61b6\u3059\u308b\u305f\u3081\u3001\u8ffd\u52a0\u6e08\u307f\u306e\u30ad\u30fc\u306b\u5bfe\u3057\u3066\u5024\u3092\u4e0a\u66f8\u304d\u3057\u3066\u3082\u633f\u5165\u4f4d\u7f6e\u306f\u4fdd\u305f\u308c\u305f\u307e\u307e\u3068\u306a\u308a\u307e\u3059\u3002\u305f\u3060\u3057\u3001\u4e00\u65e6\u9805\u76ee\u3092\u524a\u9664\u3057\u3066\u518d\u633f\u5165\u3059\u308b\u3068\u6700\u5f8c\u306b\u8ffd\u52a0\u3055\u308c\u307e\u3059\u3002<\/p>\n<h2>\u30b3\u30f3\u30b9\u30c8\u30e9\u30af\u30bf\u306e\u6ce8\u610f\u70b9<\/h2>\n<p>\u30b3\u30f3\u30b9\u30c8\u30e9\u30af\u30bf\u306e\u30ad\u30fc\u30ef\u30fc\u30c9\u5f15\u6570\u3067\u8f9e\u66f8\u306e\u8981\u7d20\u3092\u4e88\u3081\u6307\u5b9a\u3067\u304d\u308b\u306e\u3067\u3059\u304c\u3001\u3053\u306e\u65b9\u6cd5\u306f\u304a\u3059\u3059\u3081\u3057\u307e\u305b\u3093\u3002\u3068\u3044\u3046\u306e\u3082\u3001<a href=\"http:\/\/docs.python.jp\/3\/library\/collections.html#collections.OrderedDict\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">\u516c\u5f0f\u30ea\u30d5\u30a1\u30ec\u30f3\u30b9<\/a>\u306b\u3082\u8a18\u8ff0\u304c\u3042\u308b\u3068\u304a\u308a\u3001\u3053\u306e\u65b9\u6cd5\u3060\u3068\u9806\u5e8f\u304c\u4fdd\u305f\u308c\u306a\u3044\u304b\u3089\u3067\u3059\u3002<\/p>\n<div class=\"supplement \">\u30b3\u30f3\u30b9\u30c8\u30e9\u30af\u30bf\u3068 update() \u30e1\u30bd\u30c3\u30c9\u306f\u3001\u3069\u3061\u3089\u3082\u30ad\u30fc\u30ef\u30fc\u30c9\u5f15\u6570\u3092\u53d7\u3051\u4ed8\u3051\u307e\u3059\u304c\u3001\u305d\u306e\u9806\u5e8f\u306f\u5931\u308f\u308c\u307e\u3059\u3002\u3053\u308c\u306f\u3001Python \u306e\u95a2\u6570\u547c\u3073\u51fa\u3057\u306e\u610f\u5473\u3065\u3051\u306b\u304a\u3044\u3066\u3001\u30ad\u30fc\u30ef\u30fc\u30c9\u5f15\u6570\u306f\u9806\u5e8f\u4ed8\u3051\u3055\u308c\u3066\u3044\u306a\u3044\u901a\u5e38\u306e\u8f9e\u66f8\u3092\u7528\u3044\u3066\u6e21\u3055\u308c\u308b\u304b\u3089\u3067\u3059\u3002<br \/>\n<\/div>\n<p>\u4ee5\u4e0b\u306e\u30b9\u30af\u30ea\u30d7\u30c8\u3092\u4f55\u5ea6\u304b\u5b9f\u884c\u3057\u3066\u307f\u308b\u3068\u3001\u3084\u306f\u308a\u5b9f\u884c\u3059\u308b\u305f\u3073\u306b\u9806\u5e8f\u304c\u5909\u308f\u308b\u3053\u3068\u304c\u78ba\u8a8d\u3067\u304d\u307e\u3059\u3002<\/p>\n<pre class=\"brush: python; title: ; notranslate\" title=\"\">\r\ndata_dict = OrderedDict(apple= 100, orange = 80, banana = 70)\r\nfor key, val in data_dict.items():\r\n    print(key, val) # \u5b9f\u884c\u3059\u308b\u305f\u3073\u306b\u9806\u5e8f\u304c\u5909\u308f\u308b\r\n<\/pre>\n<p>\u305f\u3060\u3057\u3001\u30ad\u30fc\u30ef\u30fc\u30c9\u5f15\u6570\u306e\u4ee3\u308f\u308a\u306b\u7d44\u306e\u30b7\u30fc\u30b1\u30f3\u30b9\u3092\u4f7f\u7528\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u3001\u3053\u306e\u5834\u5408\u306f\u9806\u5e8f\u304c\u4fdd\u305f\u308c\u307e\u3059\u3002<\/p>\n<pre class=\"brush: python; title: ; notranslate\" title=\"\">\r\ndatas = [['apple', 100], ['orange', 80], ['banana', 70]]\r\ndata_dict = OrderedDict(datas)\r\nfor key, val in data_dict.items():\r\n    print(key, val)\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>\u3053\u306e\u8a18\u4e8b\u3092\u66f8\u3044\u305f\u6642\u70b9\u3001Python3.5\u3067\u306f\u8f9e\u66f8\u578b\u306f\u9806\u5e8f\u3092\u4fdd\u305f\u306a\u304b\u3063\u305f\u306e\u3067\u3059\u304c\u3001\u6a19\u6e96Python\uff08CPython\uff09\u3067\u306f3.6\u304b\u3089\u9806\u5e8f\u304c\u4fdd\u305f\u308c\u308b\u3088\u3046\u306b\u306a\u308a\u307e\u3057\u305f\u3002\u307e\u305f\u3001\u305d\u306e\u4ed6\u306e\u5b9f\u88c5\u306ePython\u3067\u30823.7\u4ee5\u964d\u9806\u5e8f\u304c\u4fdd\u305f\u308c\u308b...<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[13],"tags":[81],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/www.python.ambitious-engineer.com\/wp-json\/wp\/v2\/posts\/633"}],"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=633"}],"version-history":[{"count":8,"href":"https:\/\/www.python.ambitious-engineer.com\/wp-json\/wp\/v2\/posts\/633\/revisions"}],"predecessor-version":[{"id":3589,"href":"https:\/\/www.python.ambitious-engineer.com\/wp-json\/wp\/v2\/posts\/633\/revisions\/3589"}],"wp:attachment":[{"href":"https:\/\/www.python.ambitious-engineer.com\/wp-json\/wp\/v2\/media?parent=633"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.python.ambitious-engineer.com\/wp-json\/wp\/v2\/categories?post=633"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.python.ambitious-engineer.com\/wp-json\/wp\/v2\/tags?post=633"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}