我设法做到这一点:
import json
import pymongo
from bson import json_util
from pymongo import Connection
c = Connection()
db = c.test
collection = db.messages
for doc in collection.find({"mailbox":"bass-e"}, { "body" : "true" }):
doc
print doc
但是出来的是一个JSON对象。我想要的只是数据。我需要使用哪些包/方法来获取正文列中的文本?
答案 0 :(得分:0)
import pymongo
from pymongo import Connection
c = Connection()
db = c.test
collection = db.messages
messages = []
for doc in collection.find({"mailbox":"bass-e"}, { "body" : "true" }).limit(3):
messages.append(doc["body"])
for x in messages:
print x