PyPDF's PdfFileReader() having problems reading file, file not callable

我的未来我决定 提交于 2021-02-10 14:18:54

问题


So here is my import:

from pyPdf import PdfFileWriter, PdfFileReader

Here is were I write my pdf:

filenamer = filename + '.pdf'
pdf = PdfPages(filenamer)

(great naming convention, I know!)

I write some things to it.

I close it here:

pdf.close()

Here is where I try and read it:

input1 = PdfFileReader(file(filenamer, "rb"))

And here is the error:

Traceback (most recent call last):
  File "./datamine.py", line 405, in <module>
    input1 = PdfFileReader(file(filenamer, "rb"))
TypeError: 'file' object is not callable

I dont understand the error, because I know the file exists, and when I comment out this line, and subsequent lines to input1, the program runs fine.


回答1:


It looks like you've assigned an open file to the name file, and then you can't use the builtin any more.



来源:https://stackoverflow.com/questions/7045606/pypdfs-pdffilereader-having-problems-reading-file-file-not-callable

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!