python - 从 MongoDB Atlas 获取数据时出现“ObjectId' object is not iterable”错误
问题描述
好吧,如果我没有多大意义,请原谅我。'ObjectId' object is not iterable
每当我运行这些collections.find()
功能时,我都会面临这个问题。通过这里的答案,我不知道从哪里开始。我是编程新手,请多多包涵。
每次我到达应该从 Mongodb 获取数据的路线时,我都会得到ValueError: [TypeError("'ObjectId' object is not iterable"), TypeError('vars() argument must have __dict__ attribute')]
.
帮助
解决方案
从输出中排除“_id”。
result = collection.find_one({'OpportunityID': oppid}, {'_id': 0})
推荐阅读
- javascript - 如何使用 Angular Material DragAndDrop 设置可拖动元素的默认位置?
- tableau-api - Tableau 连接符合条件的字段
- rabbitmq - PCF 上 RabbitMQ 的 Spring AMQP 陈旧消费者
- javascript - 如何在 JavaScript 中复制指针事件的行为:无
- javascript - 通过 Javascript 直接从数组创建金属匠集合
- c - 返回变量结构成员
- java - 如果 HashMap 包含键(字符串的任何部分)
- mongodb - Percona MongoDB LDAP 身份验证
- css - 在 Windows 和 Mac 上呈现不同的滚动条
- javascript - 点击时额外刷新