2017-07-27 76 views
0

如何從一個pymongo數據庫到一個列表追加數據回顧 我目前有:作者歸屬問題

from pymongo import MongoClient 
db = MongoClient().db_name.collection_name 
reviews = [] 
with open(db) as f: 
    for line in f: 
    reviews.append(db.loads(line)) 

回答

0
from pymongo import MongoClient 
db = MongoClient().db_name.collection_name 
reviews = [] 
reviews.extend(list(db.find())) 

這將從收集數據追加到評論