PyPDF的PdfFileReader()在读取文件时遇到问题,无法调用文件 [英] PyPDF's PdfFileReader() having problems reading file, file not callable

查看:165
本文介绍了PyPDF的PdfFileReader()在读取文件时遇到问题,无法调用文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我的导入:

from pyPdf import PdfFileWriter, PdfFileReader

这是我写的pdf文件:

Here is were I write my pdf:

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

(我知道很好的命名约定!)

(great naming convention, I know!)

我写一些东西.

我在这里关闭它:

pdf.close()

这是我尝试阅读的地方:

Here is where I try and read it:

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

这是错误:

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

我不理解该错误,因为我知道文件存在,并且当我注释掉此行以及对input1的后续行时,程序运行正常.

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.

推荐答案

似乎您已将一个打开的文件分配给名称 file ,然后您将无法再使用内置文件

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

这篇关于PyPDF的PdfFileReader()在读取文件时遇到问题,无法调用文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆