使用 pymongo 连接到 MongoDB
from pymongo import MongoClient
uri = "mongodb://localhost:27017/"
client = MongoClient(uri)
db = client['test_db']
# or
# db = client.test_db
# collection = db['test_collection']
# or
collection = db.test_collection
collection.save({"hello":"world"})
print collection.find_one()