pymongo问题集合

Posted wsnan

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了pymongo问题集合相关的知识,希望对你有一定的参考价值。

1. 问题:

 

使用sort排序,代码如下:

db.test.find().sort("name" : 1, "age" : 1)  

遇到如下异常:

TypeError: if no direction is specified, key_or_list must be an instance of list  

   解决方法:

db.test.find().sort([("name", 1), ("age" , 1)])  

原因:在python中只能使用列表进行排序,不能使用字典

以上是关于pymongo问题集合的主要内容,如果未能解决你的问题,请参考以下文章