1. 安装pymongo 然后用mongod命令启动
2. 客户端操作
conn = MongoClient("localhost",27017) db = conn.test_database userInfo = db.userAcessInfo4 userInfo.delete_many({}) doc={'IP':IP,'Host':second_level_host,'TimeRange':timeRange,'ArriveTime':arrive_time} userInfo.insert_one(doc)
def showDocs(userInfo):
rs = userInfo.find()
print rs.count()
for item in rs:
pprint.pprint(item)
pass