写一段python代码,调用pymongo库中的方法 update_many删除mongodb数据库名字为db1的,名为table11的collections中的字段c1
时间: 2023-03-14 16:38:22 浏览: 70
Python使用pymongo库操作MongoDB数据库的方法实例
from pymongo import MongoClient
# connect to the MongoDB instance
client = MongoClient('localhost', 27017)
# access the database named "db1"
db = client.db1
# access the collection named "table11"
collection = db.table11
# delete the field "c1" from the collection
collection.update_many({}, {'$unset': {'c1': 1}})
阅读全文