import pymongo #导入pymongo 模块 conn = pymongo.Connection() #连接本地mongodb数据库 db=conn.database #database为数据库名称 collection = db.article #article为collection名称,相当于mysql里的表名 collection.update({'_id':ObjectId(id),'$inc':{'hit':1}}) # 为hit字段增加1 #//python/8479