文章详情页
python - Pymongo 中 update 的错误
浏览:73日期:2022-08-07 08:47:31
问题描述
首先是代码:
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’'
我一脸的蒙蔽阿。什么情况。 这个是问题是在这个主题的一个简单解决方案。这情况怎么解决?
问题解答
回答1:另外 update 已经被 deprecated ,推荐使用 update_one() 或者 update_many()https://docs.mongodb.com/gett...
回答2:提示给的很清楚啊,DB.test.update这个方法至少需要三个参数,你只传了两个参数
上一条:除了 python2 和 python3,ipython notebook 还可以用哪些内核?下一条:python - flask去掉return redirect(url_for(’index’)),结果没有变化
相关文章:
1. docker不显示端口映射呢?2. java - 请问在main方法中写成对象名.属性()并赋值,与直接参参数赋值输错误是什么原因?3. MySQL数据库中文乱码的原因4. docker - 各位电脑上有多少个容器啊?容器一多,自己都搞混了,咋办呢?5. 关docker hub上有些镜像的tag被标记““This image has vulnerabilities””6. android studio总是在processes running好久7. macos - mac下docker如何设置代理8. docker-compose 为何找不到配置文件?9. dockerfile - 我用docker build的时候出现下边问题 麻烦帮我看一下10. mysql - 新浪微博中的关注功能是如何设计表结构的?
排行榜
