{"id":558,"date":"2025-09-10T16:19:53","date_gmt":"2025-09-10T13:19:53","guid":{"rendered":"https:\/\/destek.narhost.com\/?p=558"},"modified":"2026-01-04T05:48:11","modified_gmt":"2026-01-04T02:48:11","slug":"python3-dictionary-icindeki-coklu-degerlere-nasil-ulasilir","status":"publish","type":"post","link":"https:\/\/narhost.com\/destek\/python3-dictionary-icindeki-coklu-degerlere-nasil-ulasilir\/","title":{"rendered":"Python3 Dictionary \u0130\u00e7indeki \u00c7oklu De\u011ferlere Nas\u0131l Ula\u015f\u0131l\u0131r?"},"content":{"rendered":"<p data-start=\"120\" data-end=\"265\">Narhost geli\u015ftirici ortam\u0131nda, i\u00e7 i\u00e7e s\u00f6zl\u00fck yap\u0131lar\u0131nda belirli de\u011ferlere dinamik olarak eri\u015fmek i\u00e7in <code data-start=\"223\" data-end=\"231\">reduce<\/code> fonksiyonunu kullanabilirsiniz.<\/p>\n<div class=\"contain-inline-size rounded-2xl relative bg-token-sidebar-surface-primary\">\n<div class=\"sticky top-9\">\n<div class=\"absolute end-0 bottom-0 flex h-9 items-center pe-2\">\n<div class=\"bg-token-bg-elevated-secondary text-token-text-secondary flex items-center gap-4 rounded-sm px-2 font-sans text-xs\"><\/div>\n<\/div>\n<\/div>\n<div class=\"overflow-y-auto p-4\" dir=\"ltr\">\n<p><code class=\"whitespace-pre! language-python\"><span class=\"hljs-keyword\">from<\/span> functools <span class=\"hljs-keyword\">import<\/span> reduce<\/code><\/p>\n<p><span class=\"hljs-comment\"># \u00d6rnek s\u00f6zl\u00fck yap\u0131s\u0131<\/span><br \/>\nsozluk = {<br \/>\n<span class=\"hljs-string\">&#8216;status&#8217;<\/span>: <span class=\"hljs-literal\">True<\/span>,<br \/>\n<span class=\"hljs-string\">&#8216;message&#8217;<\/span>: {<span class=\"hljs-string\">&#8216;battery&#8217;<\/span>: <span class=\"hljs-number\">35<\/span>, <span class=\"hljs-string\">&#8216;digeralan&#8217;<\/span>: <span class=\"hljs-number\">1983<\/span>},<br \/>\n<span class=\"hljs-string\">&#8216;umut&#8217;<\/span>: <span class=\"hljs-string\">&#8216;kanat&#8217;<\/span><br \/>\n}<\/p>\n<p><span class=\"hljs-comment\"># Eri\u015fmek istedi\u011fimiz anahtarlar s\u0131ral\u0131 olarak burada<\/span><br \/>\ncustom_col = (<span class=\"hljs-string\">&#8216;message&#8217;<\/span>, <span class=\"hljs-string\">&#8216;battery&#8217;<\/span>)<\/p>\n<p><span class=\"hljs-comment\"># reduce ile i\u00e7 i\u00e7e s\u00f6zl\u00fckteki de\u011feri almak i\u00e7in fonksiyon<\/span><br \/>\nsonuc = reduce(<br \/>\n<span class=\"hljs-keyword\">lambda<\/span> d, key: d.get(key, <span class=\"hljs-literal\">None<\/span>) <span class=\"hljs-keyword\">if<\/span> <span class=\"hljs-built_in\">isinstance<\/span>(d, <span class=\"hljs-built_in\">dict<\/span>) <span class=\"hljs-keyword\">else<\/span> <span class=\"hljs-literal\">None<\/span>,<br \/>\ncustom_col,<br \/>\nsozluk<br \/>\n)<\/p>\n<p><span class=\"hljs-built_in\">print<\/span>(sonuc) <span class=\"hljs-comment\"># \u00c7\u0131kt\u0131: 35<\/span><\/p>\n<\/div>\n<\/div>\n<h3 data-start=\"731\" data-end=\"751\">Nas\u0131l \u00c7al\u0131\u015f\u0131r?<\/h3>\n<ul data-start=\"752\" data-end=\"1035\">\n<li data-start=\"752\" data-end=\"875\">\n<p data-start=\"754\" data-end=\"875\"><code data-start=\"754\" data-end=\"762\">reduce<\/code> fonksiyonu, <strong data-start=\"775\" data-end=\"789\">custom_col<\/strong> i\u00e7inde tan\u0131ml\u0131 anahtarlar\u0131 s\u0131rayla al\u0131r ve s\u00f6zl\u00fck i\u00e7erisinde derinlemesine gezinir.<\/p>\n<\/li>\n<li data-start=\"876\" data-end=\"949\">\n<p data-start=\"878\" data-end=\"949\">Anahtar bulunamazsa veya eri\u015filen yap\u0131 s\u00f6zl\u00fck de\u011filse <strong data-start=\"932\" data-end=\"940\">None<\/strong> d\u00f6ner.<\/p>\n<\/li>\n<li data-start=\"950\" data-end=\"1035\">\n<p data-start=\"952\" data-end=\"1035\">Bu \u00f6rnekte <code data-start=\"963\" data-end=\"993\">sozluk['message']['battery']<\/code> de\u011ferine ula\u015f\u0131l\u0131r ve sonu\u00e7 <strong data-start=\"1021\" data-end=\"1027\">35<\/strong> olur.<\/p>\n<\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>Narhost geli\u015ftirici ortam\u0131nda, i\u00e7 i\u00e7e s\u00f6zl\u00fck yap\u0131lar\u0131nda belirli de\u011ferlere dinamik olarak eri\u015fmek i\u00e7in reduce fonksiyonunu kullanabilirsiniz.<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[12,13],"tags":[69],"class_list":["post-558","post","type-post","status-publish","format-standard","hentry","category-vds-server","category-vps-server","tag-python"],"meta_box":[],"_links":{"self":[{"href":"https:\/\/narhost.com\/destek\/wp-json\/wp\/v2\/posts\/558","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/narhost.com\/destek\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/narhost.com\/destek\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/narhost.com\/destek\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/narhost.com\/destek\/wp-json\/wp\/v2\/comments?post=558"}],"version-history":[{"count":5,"href":"https:\/\/narhost.com\/destek\/wp-json\/wp\/v2\/posts\/558\/revisions"}],"predecessor-version":[{"id":1522,"href":"https:\/\/narhost.com\/destek\/wp-json\/wp\/v2\/posts\/558\/revisions\/1522"}],"wp:attachment":[{"href":"https:\/\/narhost.com\/destek\/wp-json\/wp\/v2\/media?parent=558"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/narhost.com\/destek\/wp-json\/wp\/v2\/categories?post=558"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/narhost.com\/destek\/wp-json\/wp\/v2\/tags?post=558"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}