【发布时间】:2017-12-22 05:21:30
【问题描述】:
将 mongoengine 数据库作为列表查询我想将它们附加到可迭代的新列表中。我当前的代码:
data=[]
other_doc = Document.objects(bank="boe_dd4a95f6ec1c41ba47239fe6fd688b8cc1232c3d25a68b76836172d99164cb82")
data.append(other_doc)
other_doc_1 = Document.objects(_id="boe_585cb87956f09c48c999f90617e69038d3e8e0ceadca2b6030495d4126f4ab5d")
data.append(other_doc_1)
输出:
[[Document boe_dd4a95f6ec1c41ba47239fe6fd688b8cc1232c3d25a68b76836172d99164cb82: date=2017-03-22 12:00:00, bank=Bank boe: name=Bank of England], [Document boe_585cb87956f09c48c999f90617e69038d3e8e0ceadca2b6030495d4126f4ab5d: date=2017-04-13 09:00:00, bank=Bank boe: name=Bank of England]]
期望的输出:
[Document boe_dd4a95f6ec1c41ba47239fe6fd688b8cc1232c3d25a68b76836172d99164cb82: date=2017-03-22 12:00:00, bank=Bank boe: name=Bank of England, Document boe_585cb87956f09c48c999f90617e69038d3e8e0ceadca2b6030495d4126f4ab5d: date=2017-04-13 09:00:00, bank=Bank boe: name=Bank of England]
所以我可以运行这个:
for i in other_doc:
doc = str(other_doc.extracted_text)
doc_tokens = tokenizer.tokenize(doc)
print(doc_tokens)
【问题讨论】:
标签: python mongodb list iterable