How to close pyPDF “PdfFileReader” Class file handle

前端 未结 4 1012
青春惊慌失措
青春惊慌失措 2021-01-12 01:12

this should be very simple question, for which I couldn\'t find answer by Google search: How to close file handle opened by pyPDF \"PdfFileReader\" Class

Here is sni

4条回答
  •  陌清茗
    陌清茗 (楼主)
    2021-01-12 02:01

    If you really have to access this from the PdfFileReader object (that is: if you haven't got a reference to the file object yourself), you can use reader.stream.close()

    Note that the PdfFileReader will need an open file object to access the pdf's content (it doesn't pull everything into memory from the start), so only close the file when you are done with the reader.

提交回复
热议问题