-2
import os, os.path
from whoosh.index import create_in
from whoosh.fields import *
schema = Schema(title=TEXT(stored=True), path=ID(stored=True), content=TEXT)
if not os.path.exists("indexdir"):
os.mkdir("indexdir")
ix = create_in("indexdir", schema)
writer = ix.writer()
writer.add_document(title=u"First document", path=u"/a",
content=u"This is the first document we've added!")
writer.add_document(title=u"Second document", path=u"/b",
content=u"The second one is even more interesting!")
writer.commit()
from whoosh.qparser import QueryParser
with ix.searcher() as searcher:
query = QueryParser("content", ix.schema).parse("first")
results = searcher.search(query)
results[0]
괜찮아 보이지만 결과가 표시되지 않습니다.프로그램이 출력을 표시하지 않습니다.
print results[0]
참고 그러나 위의 코드는 파이썬 2.x 용입니다 :
그럼 당신이 어떤 인쇄 문이 없습니다. 뭘 기대 했니? –