Pymongo returns a cursor with it I am able to iterate over the results and append their documents to a list. Is there a way to get the result documents in a list directly? Thanks
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答1:
The following code will convert the entire result set (Cursor
) into a list
:
myresults = list(mydb.mycollection.find())
This is fine for relatively small result sets, as you are pulling everything into memory.