标签:port pymongo client col pip god nbsp style class
安装
pip install pymongo
import pymongo def connect_mongo(): client = pymongo.MongoClient(host=‘10.0.0.200‘, port=27017) db = client[‘lxfdb‘] # 连接数据库 db.authenticate("root", "123456") # 认证用户 return db db = connect_mongo() ret = db.collection.find() # find等于查找集合所有数据,得到的是个可迭代对象 for i in ret: print(i)
标签:port pymongo client col pip god nbsp style class
原文地址:https://www.cnblogs.com/lxfpy/p/11193907.html