[英]How to manipulate a specific field in a document (PyMongo)
例如,我在文档中有一个名为“ x”的字段,其中包含一个巨大的字符串。 我希望能够逐字读取字符串。
client = pymongo.MongoClient("localhost", 27017)
db = client.clients
collection = db.unlabel_review
for post in collection.find():
documents.append(post)
因此,这将返回整个JSON对象列表,并且在文档上调用某个索引将返回该文档。 返回该文档字段的语法是什么,例如,返回“ id”或字段“ x”(其中x包含字符串)?
直观地说,我想说
documents[1] -> returns whole JSON object so
documents[1][1] -> returns the first index of that JSON object, but this doesn't seem to work
谢谢你的帮助 :)
我想到了,
document [1] [“字段名称”]将返回特定字段。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.