亿万教师注册字典输入天生怎样中断改名

1、我是初学者,自学点点滴滴,如今遇到个题目,
mongodb数据库有这些的数据,此中huifuzhuagntai的0是未复兴的意思,1是已复兴的意思
{id:1,huifuzhuangtai:0,title:标题}
{id:1,huifuzhuangtai:1,title:标题}
{id:1,huifuzhuangtai:1,title:标题}
{id:1,huifuzhuangtai:1,title:标题}
{id:1,huifuzhuangtai:1,title:标题}
{id:1,huifuzhuangtai:1,title:标题}

2、我用管道挑选的数据,

def zong2:
    pipeline=[
        {$group:{_id:$huifuzhuangtai,counts:{$sum:1}}}
    ]
    for i in item_info.aggregatepipeline:
        data={
                name:i[_id],
                counts:i[counts]
        }
        printdata
zong2

失掉的后果是

{name: 1, counts: 5}
{name: 0, counts: 1}

我想失掉的后果是
{已复兴: 1, counts: 5}
{未复兴: 0, counts: 1}
这个怎样弄,央求大侠帮忙看看,小白太笨了

def zong2:
    pipeline=[
        {$group:{_id:$huifuzhuangtai,counts:{$sum:1}}}
    ]
    for i in item_info.aggregatepipeline:
        data={未复兴,已复兴[i[_id]]:i[counts]}
        printdata
zong2

或许

data={
    未复兴,已复兴[i[_id]]:i[_id],
    counts:i[counts]
}

(看完/读完)这篇文章有何感想! 亿万先生注册的分享…

发表评论

姓名 *
电子邮件 *
站点