How to convert a pymongo.cursor.Cursor into a dict?

前端 未结 6 1432
日久生厌
日久生厌 2020-12-02 16:18

I am using pymongo to query for all items in a region (actually it is to query for all venues in a region on a map). I used db.command(SON()) before to search i

6条回答
  •  野趣味
    野趣味 (楼主)
    2020-12-02 17:02

    I suggest create a list and append dictionary into it.

    x   = []
    cur = db.dbname.find()
    for i in cur:
        x.append(i)
    print(x)
    

    Now x is a list of dictionary, you can manipulate the same in usual python way.

提交回复
热议问题