[英]Pymongo error while trying to call distinct on a collection
I'm getting this weird error.我收到这个奇怪的错误。 I am following the documentation closely and don't understand what I am doing wrong.
我正在密切关注文档,不明白我做错了什么。 I pasted an minimal example to replicate the error.
我粘贴了一个最小的例子来复制错误。 Any tip to this fix?
此修复的任何提示?
Error message:错误信息:
TypeError: 'Collection' object is not callable. TypeError: 'Collection' object 不可调用。 If you meant to call the 'dictinct' method on a 'Collection' object it is failing because no such method exists.
如果您打算在“Collection”object 上调用“dictinct”方法,则会失败,因为不存在此类方法。
Code:代码:
import pymongo
client = pymongo.MongoClient('mongodb://localhost:27017')
detached = client['realestate'].detached
print(detached.dictinct('key_facts-build_year'))
You have a typo;你打错了; the method is
distinct()
(not dictinct()
)该方法是
distinct()
(不是dictinct()
)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.