Confused about Python's with statement

前端 未结 2 955
一整个雨季
一整个雨季 2021-02-10 03:41

I saw some code in the Whoosh documentation:

with ix.searcher() as searcher:
    query = QueryParser(\"content\", ix.schema).parse(u\"ship\")
    results = searc         


        
2条回答
  •  旧巷少年郎
    2021-02-10 04:01

    Read http://www.python.org/dev/peps/pep-0343/ it explains what the with statement is and how it looks in try .. finally form.

提交回复
热议问题