不支持的操作数类型 - :'ObjectId'和'int'

时间:2018-01-25 07:11:33

标签: mongodb ubuntu

mongodb中上传/更新列时:

persona.update_many({u"_id":(result["_id"])},{"$set": {column_name:df1.iloc[:,m][(list(result.values())[1])-1]}})

我收到此错误:

unsupported operand type(s) for -: 'ObjectId' and 'int'

enter image description here

1 个答案:

答案 0 :(得分:0)

来自bson import ObjectId

persona.update_many({"_id":ObjectId(result["_id"])},{"$set": {column_name:df1.iloc[:,m][(list(result.values())1)-1]}})

插入ObjectId它将解决问题