import pymongo,sys
from pymongo import MongoClient
client = MongoClient(host="localhost:27017",read_preference=pymongo.read_preferences.ReadPreference.PRIMARY_PREFERRED)
db = client.database
db.authenticate("database","passwd) ")
1.search
pi = db.locinfo.find({"con":p}) #search
pi = db.locinfo.find_one({"con":p})
print pi
{u' city': u'u56feu6728u8212u514bu5e02'、u'wid': u'101130908'、u'zip': u'843900'、u'pro': u'u65b0u7586u7ef4u543eu5c14u81eau6cbbu533a'、u'wkey': u'u56feu672 8u8212u514bu5e02'、u' acode': u'0998'、u'_id': u'txpcx5'、u'fix': True、u'con': u'u56feu6728u8212u514bu5e02'}
2.update
db.locinfo.update({" con":p},{'$set':{"con":zc}}) # 1 つのアイテムを更新します
×××××××××××××××批量update ××× multi=True × ×××××××××××××××××××××××××××××××
db.locinfo.update({"con":lon},{'$set ':{"wkey": sht }},multi=True) #ok,# 複数の項目を更新します
×××××××××××××××××××××××××× ×××××××××××××××××××××××××××××××××××
3.insert # 插入量组,及び一般字符窜
db .wbinfo.insert({"city":cityname,"jiaojing":[jiaojing],"lukuang":"lukuang,"})
4.push、pop 插入组、删除数组元素
db.wbinfo.update( {"city":"六安市"},{'$push':{"jiaojing":"two","lukuang":"lk"}})
db.wbinfo.update({"city":"六安市"},{'$pop':{"jiaojing":"two","lukuang":"lk"}})
5. 正则查询
res = db.devices.find({'$and':[{'stats.devcaps':{'$exists':True}},{'stats.fwver':{'$regex':'. *N91|N92.*'}}]}) # stats.fwver 字段包含文字符 'N91' または 'N92'
6.字典
if devcap.has_key('dev') および devcap.has_key('cap') :
7.
pythonoperatemongodbベース_id_id查询データの代価
ObjectId pymongo python
結果pymongoのバージョン番号が2.2より小さい、次の句を使用してObjectId
from pymongo.objectid import ObjectId
結果pymongoのバージョン番号が2.2より大きい、以下を使用しますの句句
from bson.objectid import ObjectId
查询代码如下:
collection.find_one({'_id':ObjectId('50f0d76347f4ec148890ef1e')})

Pythonlistscanstoreanydatatype,arraymodulearraysstoreonetype,andNumPyarraysarefornumericalcomputations.1)Listsareversatilebutlessmemory-efficient.2)Arraymodulearraysarememory-efficientforhomogeneousdata.3)NumPyarraysareoptimizedforperformanceinscient

heouttemptemptostoreavure ofthewrongdatatypeinapythonarray、yure counteractypeerror.thisduetothearraymodule'sstricttypeeencultionyを使用します

PythonListSarePartOfThestAndardarenot.liestareBuilting-in、versatile、forStoringCollectionsのpythonlistarepart。

theScriptisrunningwithwrongthonversionduetorectRectDefaultEntertersettings.tofixthis:1)CheckthedededefaultHaulthonsionsingpython - versionorpython3-- version.2)usevirtualenvironmentsbycreatingonewiththon3.9-mvenvmyenv、andverixe

PythonArraysSupportVariousoperations:1)SlicingExtractsSubsets、2)Appending/ExtendingAdddesements、3)inSertingSelementSatspecificpositions、4)remvingingDeletesements、5)sorting/verversingsorder、and6)listenionsionsionsionsionscreatenewlistsebasedexistin

numpyarraysAressertialentionsionceivationsefirication-efficientnumericalcomputations andDatamanipulation.theyarecrucialindatascience、mashineelearning、物理学、エンジニアリング、および促進可能性への適用性、scaledatiencyを効率的に、forexample、infinancialanalyyy

UseanArray.ArrayOverAlistinPythonは、Performance-criticalCode.1)homogeneousdata:araysavememorywithpedelements.2)Performance-criticalcode:Araysofterbetterbetterfornumerumerumericaleperations.3)interf

いいえ、notallistoperationSaresuptedbyarrays、andviceversa.1)arraysdonotsupportdynamicoperationslikeappendorintorintorinsertizizing、whosimpactsporformance.2)リスト


ホットAIツール

Undresser.AI Undress
リアルなヌード写真を作成する AI 搭載アプリ

AI Clothes Remover
写真から衣服を削除するオンライン AI ツール。

Undress AI Tool
脱衣画像を無料で

Clothoff.io
AI衣類リムーバー

Video Face Swap
完全無料の AI 顔交換ツールを使用して、あらゆるビデオの顔を簡単に交換できます。

人気の記事

ホットツール

ゼンドスタジオ 13.0.1
強力な PHP 統合開発環境

AtomエディタMac版ダウンロード
最も人気のあるオープンソースエディター

ドリームウィーバー CS6
ビジュアル Web 開発ツール

WebStorm Mac版
便利なJavaScript開発ツール

DVWA
Damn Vulnerable Web App (DVWA) は、非常に脆弱な PHP/MySQL Web アプリケーションです。その主な目的は、セキュリティ専門家が法的環境でスキルとツールをテストするのに役立ち、Web 開発者が Web アプリケーションを保護するプロセスをより深く理解できるようにし、教師/生徒が教室環境で Web アプリケーションを教え/学習できるようにすることです。安全。 DVWA の目標は、シンプルでわかりやすいインターフェイスを通じて、さまざまな難易度で最も一般的な Web 脆弱性のいくつかを実践することです。このソフトウェアは、

ホットトピック









