我对包括解释在内的要求有问题。 作为一个例子,下面的请求可以很好地工作:
pp.pprint(col.find({"cuisine":"Italian"}, {"name" : 1, "address.zipcode" : 1, "address.coord" : 1}).explain())
解释方法的项目清单打印得很好。在
但是,当我只需要explain()方法中的executionStats项时,请求如下:
^{pr2}$我有以下错误:
TypeError: explain() takes 1 positional argument but 2 were given
有人知道这是怎么回事,怎么解决这个问题吗?在
泰
在pymongo中不能传递“executionStats”来解释。必须让pymongo的explain包装器获取所有explain输出并解析出所需的内容。在
在pp.p打印(col.查找({“烹饪”:“意大利语”},{“名称”:1地址.zipcode“:1,”地址.coord“:1}).explain())
见https://api.mongodb.org/python/current/api/pymongo/cursor.html?highlight=explain#pymongo.cursor.Cursor.explain
没有争论。在
在pymongo中explain()是一个dic,所以需要add key来显示“executionStats”
相关问题 更多 >
编程相关推荐