TypeError: 'Collection' object is not callable. If you meant to call the 'authenticate' method on a 'Database' object it is failing because no such method exists.
原因:
pymong4变动。
解决:
1.时光机回到过去,安装pymongo低版本。
2.在登录命令中,直接把databasename加进去。
我的代码如下。没有被引号引起来的,就是变量。大家提前设置好。
mongologin = "mongodb://"+username+":"+password+"@"+server+":27017/"+db_name
client = pymongo.MongoClient(mongologin)
db1 = client[db_name]
collection = db1[table_name]