這篇“python中怎么刪除文檔”文章的知識點大部分人都不太理解,所以小編給大家總結(jié)了以下內(nèi)容,內(nèi)容詳細,步驟清晰,具有一定的借鑒價值,希望大家閱讀完這篇文章能有所收獲,下面我們一起來看看這篇“python中怎么刪除文檔”文章吧。
在內(nèi)丘等地區(qū),都構(gòu)建了全面的區(qū)域性戰(zhàn)略布局,加強發(fā)展的系統(tǒng)性、市場前瞻性、產(chǎn)品創(chuàng)新能力,以專注、極致的服務理念,為客戶提供成都網(wǎng)站建設、網(wǎng)站建設 網(wǎng)站設計制作按需求定制網(wǎng)站,公司網(wǎng)站建設,企業(yè)網(wǎng)站建設,成都品牌網(wǎng)站建設,成都全網(wǎng)營銷,外貿(mào)網(wǎng)站制作,內(nèi)丘網(wǎng)站建設費用合理。
1、delete_one()方法刪除文檔。delete_one()需要一個查詢對象參數(shù)。它只刪除了第一次出現(xiàn)。
2、在刪除大量文檔時,使用delete_many方法,需要查詢對象。
如果我們向delete_many({})傳e_many({}),它將刪除集合中的所有文檔。
實例
# 讓我們 從 Flask 導入Flask import Flask , render_template import os # 導入操作系統(tǒng)模塊 import pymongo MongoDB_URI = 'mongodb+srv://asabeneh:your_password_goes_here@30daysofpython-twxkr.mongodb.net/test?retryWrites=true&w=majority' client = pymongo.MongoClient(MONGODB_URI) db = client['thirty_days_of_python'] # accessing the database query = {'name':'John'} db.students.delete_one(query) for student in db.students.find(): print(student) # lets check the result if the age is modified for student in db.students.find(): print(student) app = Flask(__name__) if __name__ == '__main__': # for deployment we use the environ # to make it work for both production and development port = int(os.environ.get("PORT", 5000)) app.run(debug=True, host='0.0.0.0', port=port)
以上就是關于“python中怎么刪除文檔”這篇文章的內(nèi)容,相信大家都有了一定的了解,希望小編分享的內(nèi)容對大家有幫助,若想了解更多相關的知識內(nèi)容,請關注創(chuàng)新互聯(lián)行業(yè)資訊頻道。
新聞標題:python中怎么刪除文檔
瀏覽地址:http://bm7419.com/article36/pciosg.html
成都網(wǎng)站建設公司_創(chuàng)新互聯(lián),為您提供虛擬主機、云服務器、關鍵詞優(yōu)化、做網(wǎng)站、網(wǎng)站維護、商城網(wǎng)站
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)