你们能帮我解决这个问题吗?Client.list_databse_names()打印列表,但下一行抛出以下错误。
File "/usr/local/lib/python3.6/dist-packages/pymongo/collection.py", line 3339,
in __call__self.__name)
TypeError: 'Collection' object is not callable.
If you meant to call the 'find' method on a 'Database' object it is failing
because no such method exists.
Run Code Online (Sandbox Code Playgroud)
这是代码
import pymongo
client =pymongo.MongoClient('mongodb+srv://server:password@cluster-sre.mongodb.net/test?retryWrites=true&w=majority')
print(client.list_database_names()) // outputs : ['data', 'admin', 'local']
results = client.locations.find({"city": "Bangalore"})
print(results)
Run Code Online (Sandbox Code Playgroud)
还尝试使用“client.locations.findOne()”相同的错误消息。