使用MongoDB循环和组合数组?

2024-05-23 18:34:03 发布

您现在位置:Python中文网/ 问答频道 /正文

我想知道是否可以在mongo文档中为单个键提供多个字符串值?我正在将mongo与python flak应用程序连接,遇到了一些令人沮丧的困难。我会在这里更好地解释自己:

{"_id": {"$oid": "5c0c0843e7179a2e2704fe86"
},
"category_name": "Breakfast",
"recipe_name": "Scambled Egg",
"recipe_ingredients": [
"Eggs",
"1/4 cup of Milk",
"2 tsp. Butter"
],
"recipe_servings": 2,
"recipe_author": "Sally Reynolds",
"recipe_calories": 192,
"recipe_country_of_origin": "England",
"step_one": "BEAT eggs, milk, salt and pepper in medium bowl until blended., HEAT butter in large nonstick skillet over medium heat until hot. POUR IN egg mixture, GENTLY PULL the eggs across the pan with a spatula, forming large soft curds.",
"prep_time": "1 Minute",
"cooking_time": "4 Minutes",
"vegan": "false"enter 
}

在recipe_Components中,是否可以包含所有这三个字符串而不在浏览器上获得此响应:

[u'Eggs', u'1/4 cup of Milk', u'2 tsp. Butter']

我只想展示这三个项目


Tags: of字符串nameinmongorecipeeggscup