1、使用pymongo操作mongodb简单示例

#!/usr/bin/env python
# -*- coding:utf-8 -*-

import pymongo

mon_conn = pymongo.Connection('192.168.10.1', 27017)
db = mon_conn.db_teams

collectionlist = db.collection_names()

for collection in collectionlist:
    print "%-10s" % collection,db[collection].find().count()