我有一个像json的
d = {"id": 1, "company_car": 1, "manufacture_stage": OrderedDict([("id", 4), ("company", OrderedDict([("id", 1), ("name", "BMW"), ("icon", "http://test.com/ta/")]))]), "manufacture_car_stage_status": "Scheduled", "start_datetime": "2019-04-30 17:24:32", "end_datetime": "2019-05-30 17:54:32", "taken_datetime": None, "is_active": true, "manufacture_car_stage_detail": {"assessment_scores": None}, "is_shortlisted": false, "is_rejected": false}
我如何获得oderedDict具有name
值的BMW
?
答案 0 :(得分:2)
您以与普通词典相同的方式访问OrderedDict
的键
<!-- Header -->
<header>
<nav id='cssmenu'>
<div class="logo"><a href='/home'><img src="https://files.spazioweb.it/8e/06/8e06738d-73f4-4948-ba5b-55ebd58861fb.png" width="200"></a></div>
<div id="head-mobile"></div>
<div class="botton"></div>
<ul>
<li><a href="/home">Home</a></li>
<li><a href="/chi-siamo">Azienda</a></li>
<li><a href="/assistenza">Assistenza</a></li>
<li><a href="/revisione">Revisione</a></li>
<li><a href='/trasloco-macchine'>Trasloco macchine</a></li>
<li><a href='/servizi'>Altri servizi</a>
<ul>
<li><a href='/servizi2/torrette'>Torrette</a></li>
<li><a href='/servizi2/mandrini'>Mandrini</a></li>
<li><a href='/servizi2/trasportatore-trucioli'>Trasportatore trucioli</a></li>
<li><a href='/servizi2/ripristino-turcite'>Ripristino turcite</a></li>
<li><a href='/servizi2/automazione-industriale'>Automazione industriale</a></li>
<li><a href='/servizi2/messa-a-norma'>Messa a norma</a></li>
<li><a href='/servizi2/pulizia-macchine-utensili'>Pulizia macchine</a></li>
</ul>
</li>
<li><a href='/ricambi'>Ricambi</a></li>
<li><a href='/contatti'>Contatti</a></li>
</ul>
</nav>
</header>
<style>
@media screen and (max-width:1000px){
.logo {
display: block;
padding: 10;
width: 100%;
margin-left: 20px;
text-align: left;
float: none;
}
.logo2{display:none}
nav{width:100%;}
#cssmenu{width:97%; margin-top:3px;}
#cssmenu ul{width:100%;display:none; margin-top: -50px;}
#cssmenu ul li{width:100%;border-bottom:0px solid #444; color: #ea5b0c; margin-left: 0px;}
#cssmenu ul li:hover{background:#f2f2f2; color:black;}
#cssmenu ul ul li,#cssmenu li:hover > ul > li{height:auto}
#cssmenu ul li a,#cssmenu ul ul li a{width:100%;border-bottom:0}
#cssmenu > ul > li{float:none}
#cssmenu ul ul li a{padding-left:35px}
#cssmenu ul ul li{background:#f2f2f2!important;}
#cssmenu ul ul li:hover{background:#f2f2f2!important;}
#cssmenu ul ul ul li a{padding-left:35px}
#cssmenu ul ul li a{color:#ea5b0c;background:none}
#cssmenu ul ul li:hover > a,#cssmenu ul ul li.active > a{color:black;}
#cssmenu ul ul,#cssmenu ul ul ul{
position:relative;
left:0;
width:100%;
margin:0;
text-align:left}
#cssmenu > ul > li.has-sub > a:after,#cssmenu > ul > li.has-sub > a:before,#cssmenu ul ul > li.has-sub > a:after,#cssmenu ul ul > li.has-sub > a:before{display:none}
#cssmenu #head-mobile{
display:block;
padding:23px;
color:#ddd;
font-size:12px;
font-weight:400;
}
.botton{
margin-top: 10px;
width:55px;
height:46px;
position:absolute;
right:0;
top:0;
cursor:pointer;
z-index: 12399994;
}
.botton:after{
position:absolute;
top:22px;
right:20px;
display:block;
height:8px;
width:18px;
border-top:2px solid black;
border-bottom:2px solid black;
content:''}
.botton:before{
-webkit-transition:all .3s ease;
-ms-transition:all .3s ease;
transition:all .3s ease;
position:absolute;
top:16px;
right:20px;
display:block;
height:2px;
width:18px;
background:black;
content:''}
.botton.menu-opened:after{
-webkit-transition:all .3s ease;
-ms-transition:all .3s ease;
transition:all .3s ease;
top:23px;
border:0;
height:2px;
width:17px;
background:black;
-webkit-transform:rotate(45deg);
-moz-transform:rotate(45deg);
-ms-transform:rotate(45deg);
-o-transform:rotate(45deg);
transform:rotate(45deg)}
.botton.menu-opened:before{
top:23px;
background:black;
width:17px;
-webkit-transform:rotate(-45deg);
-moz-transform:rotate(-45deg);
-ms-transform:rotate(-45deg);
-o-transform:rotate(-45deg);
transform:rotate(-45deg)}
#cssmenu .submenu-button{
position:absolute;
z-index:99;
right:0;
top:0;
display:block;
border-left:0px solid #444;
height:36px;
width:46px;
cursor:pointer}
#cssmenu .submenu-button.submenu-opened{background:#f2f2f2}
#cssmenu ul ul .submenu-button{
height:34px;
width:34px}
#cssmenu .submenu-button:after{
position:absolute;
top:3px;
right:21px;
width:8px;
height:2px;
display:block;
background:black;
content:''}
#cssmenu ul ul .submenu-button:after{
top:18px;
right:21px}
#cssmenu .submenu-button.submenu-opened:after{background:#000000;}
#cssmenu .submenu-button:before{
position:absolute;
top:0px;
right:24px;
display:block;
width:2px;
height:8px;
background:black;
content:''}
#cssmenu ul ul .submenu-button:before{top:15px;right:24px;}
#cssmenu .submenu-button.submenu-opened:before{display:none}
#cssmenu ul ul ul li.active a{border-left:none}
#cssmenu > ul > li.has-sub > ul > li.active > a,#cssmenu > ul ul > li.has-sub > ul > li.active > a{border-top:none}
}
<script>
(function($) {
$.fn.menumaker = function(options) {
var cssmenu = $(this), settings = $.extend({
format: "dropdown",
sticky: false
}, options);
return this.each(function() {
$(this).find(".botton").on('click', function(){
$(this).toggleClass('menu-opened');
var mainmenu = $(this).next('ul');
if (mainmenu.hasClass('open')) {
mainmenu.slideToggle().removeClass('open');
}
else {
mainmenu.slideToggle().addClass('open');
if (settings.format === "dropdown") {
mainmenu.find('ul').show();
}
}
});
cssmenu.find('li ul').parent().addClass('has-sub');
multiTg = function() {
cssmenu.find(".has-sub").prepend('<span class="submenu-button"></span>');
cssmenu.find('.submenu-button').on('click', function() {
$(this).toggleClass('submenu-opened');
if ($(this).siblings('ul').hasClass('open')) {
$(this).siblings('ul').removeClass('open').slideToggle();
}
else {
$(this).siblings('ul').addClass('open').slideToggle();
}
});
};
if (settings.format === 'multitoggle') multiTg();
else cssmenu.addClass('dropdown');
if (settings.sticky === true) cssmenu.css('position', 'fixed');
resizeFix = function() {
var mediasize = 1000;
if ($( window ).width() > mediasize) {
cssmenu.find('ul').show();
}
if ($(window).width() <= mediasize) {
cssmenu.find('ul').hide().removeClass('open');
}
};
resizeFix();
return $(window).on('resize', resizeFix);
});
};
})(jQuery);
(function($){
$(document).ready(function(){
$("#cssmenu").menumaker({
format: "multitoggle"
});
});
})(jQuery);
</script>