我正在使用pymongo
將數據寫入MongoDB
。pymongo - TypeError:文檔必須是dict,bson.son.SON或從集合繼承的其他類型的實例。可變馬賽克
執行寫入操作時收到此錯誤。
TypeError: document must be an instance of dict, bson.son.SON, or other type that inherits from collections.MutableMapping
如果我打印的數據,並與insert_one()
調用複製,信息與外殼寫入。我試圖將該變量轉換爲str,但我不確定它是如何格式不正確的,就像我複製打印行並執行操作一樣,它被添加。這導致我懷疑JSON對象的格式沒有問題,但是它是編碼或其一些變體,或者返回的JSON對象的小語法。
post_id = post_db.insert_one(chunk).inserted_id
您可以添加塊變量的內容嗎? –