首先,下載安裝Python.
然後下載PyMongo.
打開Python Shell,新建一個py文件,在裏面敲入代碼:
import pymongo
// 如何數據庫在服務器上,將localhost改爲IP地址,端口號也做相應更改。
client=pymongo.MongoClient("localhost",27017)
// 連接test數據庫
db=client.test
// 訪問test數據庫中things集合
collection=db.things
// 遍歷集合中的文檔
for m in collection.find():
print(m)
點擊“run”下的“Run Module”運行,運行結果爲: