新聞中心
這里有您想知道的互聯(lián)網(wǎng)營銷解決方案
創(chuàng)新互聯(lián)Python教程:python中MongoDB的增刪改查
1、說明

創(chuàng)新互聯(lián)建站主營歷城網(wǎng)站建設(shè)的網(wǎng)絡(luò)公司,主營網(wǎng)站建設(shè)方案,app開發(fā)定制,歷城h5微信平臺小程序開發(fā)搭建,歷城網(wǎng)站營銷推廣歡迎歷城等地區(qū)企業(yè)咨詢
MongoDB使用查看數(shù)據(jù)的功能時(shí)非常方便。能立即看到增刪改查的數(shù)據(jù),無需操作命令行即可查看。
2、方法實(shí)例
(1)增
# 增加一條記錄
person = {'name': 'zone','sex':'boy'}
person_id = test.insert_one(person).inserted_id
print(person_id)(2)刪
# 刪除單條記錄
result1 = test.delete_one({'name': 'zone'})
pprint.pprint(result1)(3)改
# 更新單條記錄
res = test.update_one({'name': 'zone'}, {'$set': {'sex': 'girl girl'}})
print(res.matched_count)(4)查
# 查找多條記錄
pprint.pprint(test.find())
# 添加查找條件
pprint.pprint(test.find({"sex": "boy"}).sort("name"))以上就是python中MongoDB增刪改查的操作,希望對大家有所幫助。更多Python高級指路:python創(chuàng)新互聯(lián)教程
本文教程操作環(huán)境:windows7系統(tǒng)、Python 3.9.1,DELL G3電腦。
分享題目:創(chuàng)新互聯(lián)Python教程:python中MongoDB的增刪改查
文章分享:http://www.dlmjj.cn/article/cdjjgdo.html


咨詢
建站咨詢
