首页 > 解决方案 > 从 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')].

帮助

标签: pythonmongodbapiobjectid

解决方案


从输出中排除“_id”。

result = collection.find_one({'OpportunityID': oppid}, {'_id': 0})

推荐阅读