python - Pymongo 中 update 的错误
迷茫
迷茫 2017-04-18 10:31:54
0
2
549

首先是代码:

DB.test.update(query={'host': ip, 'port': port}, update={$set: {'http': 'test'}})

这个代码会报这样的错误:

TypeError: 'update() takes at least 3 arguments (1 given)

在这个之前我使用了最最简单的:

DB.test.update({'host': ip, 'port': port}, {"$set": {'http': 'test'}})

报的错误:

TypeError: "unhashable type: 'dict'"

我一脸的蒙蔽阿。什么情况。 这个是问题是在这个主题的一个简单解决方案。这情况怎么解决?

迷茫
迷茫

业精于勤,荒于嬉;行成于思,毁于随。

reply all(2)
大家讲道理

In addition, update has been deprecated, it is recommended to use update_one() or update_many()
https://docs.mongodb.com/gett...

黄舟

The prompt is very clear. The DB.test.update method requires at least three parameters, and you only passed two parameters

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!