gpt4 book ai didi

python - 获取特定键的所有值

转载 作者:行者123 更新时间:2023-12-01 22:20:43 26 4
gpt4 key购买 nike

我在 mongoDB 中有一个数据,我想使用 python 代码检索键 "category" 的所有值。我尝试了几种方法,但在每种情况下我都必须给出要检索的“值”。如有任何建议,我们将不胜感激。

{
id = "my_id1"
tags: [tag1, tag2, tag3],
category: "movie",
},
{
id = "my_id2"
tags: [tag3, tag6, tag9],
category: "tv",
},
{
id = "my_id3"
tags: [tag2, tag6, tag8],
category: "movie",
}

我想要输出为

category: "movie"
category: "tv"
category: "movie"

最佳答案

这应该可行

db.test.find({},{"category":1});

关于python - 获取特定键的所有值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40282812/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com