python 遍历mongo db集合文档

时间:2021-02-23 14:03:33   收藏:0   阅读:0
# -*- coding: UTF-8 -*-
import pymongo
# 连接数据库
client = pymongo.MongoClient(localhost,27017)
db=client[qunar]
collection=db[departures]
# 读取数据
data = collection.find()
for item in data:
    print(item[departure])

澳门
阿坝州
阿克苏地区
阿拉尔
阿拉善盟
阿勒泰
阿里
安康
安庆
鞍山
安顺
安阳
北京
白城
百色
白沙
白山

评论(0
© 2014 mamicode.com 版权所有 京ICP备13008772号-2  联系我们:gaon5@hotmail.com
迷上了代码!