Reputation: 1179
I am using pymongo and I am doing a query on structure that is basically a nest dict inside my document.
From what I have read the best way to handle this is to turn the pymongo cursor into a list and try to loop over the listed dictionary. My data now looks like this.
>>> myDict
[{'nestedDict': {'c': '3', 'a': '1', 'b': '2'}}]
how can loop this to get the keys values of a, b and c?
got it
>>> for key, value in myDict[0]['nestedDict'].items():
... print(key, value)
...
c 3
a 1
b 2
>>>
Upvotes: 0
Views: 178