Pymongo - TypeError: index 'xxxx' cannot be applied to Cursor instances

最近在使用pymongo过程中,遇到如标题问题

始终不得其解,最后gg解决


原因如下:

    find() method will always return a full cursor rather than a single document, even if the where clause specifies the primary key field, _id


解决方法:

    The solution was clear: replace the find() method with the find_one() method to return a document rather than a cursor

你可能感兴趣的:(python)