我正在使用pymongo,我正在对结构进行查询,该查询基本上是我文档中的嵌套字典。
根据我的阅读,处理此问题的最佳方法是将pymongo光标转换为列表并尝试遍历列出的字典。我的数据现在看起来像这样。
$ sed '/102/ s#$#/&#' file11
101|abc|this is desc|2017
102|xyz|"thie is a long desc/
des for xyz continue here."|2017
如何循环获取a,b和c的键值?
得到它
>>> myDict
[{'nestedDict': {'c': '3', 'a': '1', 'b': '2'}}]
答案 0 :(得分:1)
你需要这样的东西吗?
myDict[0]['nestedDict']['b']
'2'