我有2个ordereddict列表,我通过函数从DB中获取它们,它们看起来如下
首先列出打印输出:
$rootScope.$on('credit-changed',function(event,data){
$scope.credit = data;
})
第二个列表打印输出:
OrderedDict([('Items', '1'), ('Itemspaid', 'Rutr'), ('First', 'Het'), ('Second', 'Fru'), ('Third', 'yurn'), ('Flip', 223.513353868968)])
OrderedDict([('Items', '2'), ('Itemspaid', 'Rutr'), ('First', 'Het'), ('Second', 'Fru'), ('Third', 'yurn'), ('Flip', 243.513353868968)])
OrderedDict([('Items', '3'), ('Itemspaid', 'Rutr'), ('First', 'Het'), ('Second', 'Fru'), ('Third', 'yurn'), ('Flip', 263.513353868968)])
OrderedDict([('Items', '4'), ('Itemspaid', 'Rutr'), ('First', 'Het'), ('Second', 'Fru'), ('Third', 'yurn'), ('Flip', 323.513353868968)])
OrderedDict([('Items', '5'), ('Itemspaid', 'Rutr'), ('First', 'Het'), ('Second', 'Fru'), ('Third', 'yurn'), ('Flip', 333.513353868968)])
OrderedDict([('Items', '6'), ('Itemspaid', 'Rutr'), ('First', 'Het'), ('Second', 'Fru'), ('Third', 'yurn'), ('Flip', 343.513353868968)])
OrderedDict([('Items', '7'), ('Itemspaid', 'Rutr'), ('First', 'Het'), ('Second', 'Fru'), ('Third', 'yurn'), ('Flip', 353.513353868968)])
OrderedDict([('Items', '8'), ('Itemspaid', 'Rutr'), ('First', 'Het'), ('Second', 'Fru'), ('Third', 'yurn'), ('Flip', 13.513353868968)])
OrderedDict([('Items', '9'), ('Itemspaid', 'Rutr'), ('First', 'Het'), ('Second', 'Fru'), ('Third', 'yurn'), ('Flip', 123.513353868968)])
OrderedDict([('Items', '10'), ('Itemspaid', 'Rutr'), ('First', 'Het'), ('Second', 'Fru'), ('Third', 'yurn'), ('Flip', 162.513353868968)])
OrderedDict([('Items', '11'), ('Itemspaid', 'Rutr'), ('First', 'Het'), ('Second', 'Fru'), ('Third', 'yurn'), ('Flip', 213.513353868968)])
我想从第二个列表中获取每个Flip值并用第一个列表的所有Flip值减去该值,并将相应的键值对插入第一个列表中,其中值之间的差异如下所示,这是为了维持第一个列表值的顺序(因为它们已经排序)
步骤:
OrderedDict([('planneditems', '1'), ('plannedItemspaid', 'pRutr'), ('PlannedFirst', 'pHet'), ('PlannedSecond', 'pFru'), ('PlannedThird', 'pyurn'), ('Flip', 23.513353868968)])
OrderedDict([('planneditems', '4'), ('plannedItemspaid', 'pRutr'), ('PlannedFirst', 'pHet'), ('PlannedSecond', 'pFru'), ('PlannedThird', 'pyurn'), ('Flip', 113.513353868968)])
OrderedDict([('planneditems', '5'), ('plannedItemspaid', 'pRutr'), ('PlannedFirst', 'pHet'), ('PlannedSecond', 'pFru'), ('PlannedThird', 'pyurn'), ('Flip', 133.513353868968)])
OrderedDict([('planneditems', '6'), ('plannedItemspaid', 'pRutr'), ('PlannedFirst', 'pHet'), ('PlannedSecond', 'pFru'), ('PlannedThird', 'pyurn'), ('Flip', 213.513353868968)])
在上面的结果中,第一个列表的翻转值13.513353868968的差异较小,所以我需要从第二个列表中选择翻转值23.513353868968的键值对
Take first flip value of second list : 23.513353868968
Subtract this with all the flip values of first list
23.513353868968 - 223.513353868968 = -200 (ignore the sign)
23.513353868968 - 243.513353868968 = 220
23.513353868968 - 263.513353868968 = 240
23.513353868968 - 323.513353868968 = 300
23.513353868968 - 333.513353868968 = 313
23.513353868968 - 343.513353868968 = 320
23.513353868968 - 13.513353868968 = 10
23.513353868968 - 123.513353868968 = 100
23.513353868968 - 162.513353868968 = 139
23.513353868968 - 213.513353868968 = 190
并将其放在第一个较小差异和第二个较小差异之间,即必须在第一个列表中的第8行旁边
像这样我想从第二个列表中获取所有值并重复相同的事情,最后根据自定义排序插入第二个列表,它们也应该在自己内部排序
新列表预期打印输出:
OrderedDict([('planneditems', '1'), ('plannedItemspaid', 'pRutr'), ('PlannedFirst', 'pHet'), ('PlannedSecond', 'pFru'), ('PlannedThird', 'pyurn'), ('Flip', 23.513353868968)])
我尝试了下面的代码,我无法按预期工作,它打印出最后一个条目,任何帮助将不胜感激。
OrderedDict([('Items', '1'), ('Itemspaid', 'Rutr'), ('First', 'Het'), ('Second', 'Fru'), ('Third', 'yurn'), ('Flip', 223.513353868968)])
OrderedDict([('Items', '2'), ('Itemspaid', 'Rutr'), ('First', 'Het'), ('Second', 'Fru'), ('Third', 'yurn'), ('Flip', 243.513353868968)])
OrderedDict([('Items', '3'), ('Itemspaid', 'Rutr'), ('First', 'Het'), ('Second', 'Fru'), ('Third', 'yurn'), ('Flip', 263.513353868968)])
OrderedDict([('Items', '4'), ('Itemspaid', 'Rutr'), ('First', 'Het'), ('Second', 'Fru'), ('Third', 'yurn'), ('Flip', 323.513353868968)])
OrderedDict([('Items', '5'), ('Itemspaid', 'Rutr'), ('First', 'Het'), ('Second', 'Fru'), ('Third', 'yurn'), ('Flip', 333.513353868968)])
OrderedDict([('Items', '6'), ('Itemspaid', 'Rutr'), ('First', 'Het'), ('Second', 'Fru'), ('Third', 'yurn'), ('Flip', 343.513353868968)])
OrderedDict([('Items', '7'), ('Itemspaid', 'Rutr'), ('First', 'Het'), ('Second', 'Fru'), ('Third', 'yurn'), ('Flip', 353.513353868968)])
OrderedDict([('Items', '8'), ('Itemspaid', 'Rutr'), ('First', 'Het'), ('Second', 'Fru'), ('Third', 'yurn'), ('Flip', 13.513353868968)])
OrderedDict([('planneditems', '1'), ('plannedItemspaid', 'pRutr'), ('PlannedFirst', 'pHet'), ('PlannedSecond', 'pFru'), ('PlannedThird', 'pyurn'), ('Flip', 23.513353868968)])
OrderedDict([('planneditems', '4'), ('plannedItemspaid', 'pRutr'), ('PlannedFirst', 'pHet'), ('PlannedSecond', 'pFru'), ('PlannedThird', 'pyurn'), ('Flip', 113.513353868968)])
OrderedDict([('Items', '9'), ('Itemspaid', 'Rutr'), ('First', 'Het'), ('Second', 'Fru'), ('Third', 'yurn'), ('Flip', 123.513353868968)])
OrderedDict([('Items', '10'), ('Itemspaid', 'Rutr'), ('First', 'Het'), ('Second', 'Fru'), ('Third', 'yurn'), ('Flip', 162.513353868968)])
OrderedDict([('Items', '11'), ('Itemspaid', 'Rutr'), ('First', 'Het'), ('Second', 'Fru'), ('Third', 'yurn'), ('Flip', 213.513353868968)])
OrderedDict([('planneditems', '6'), ('plannedItemspaid', 'pRutr'), ('PlannedFirst', 'pHet'), ('PlannedSecond', 'pFru'), ('PlannedThird', 'pyurn'), ('Flip', 213.513353868968)])
答案 0 :(得分:0)
"schematics": {
"@schematics/angular:component": {
"styleext": "scss"
}
}
Output与您的预期输出不符,但我确定您的预期装备无论如何都是正确的(例如,计划中的第5项缺失)。