pypdf 错误 - 模块对象没有属性 number
这是我正在使用的代码:
import os
import decimal
from pyPdf import PdfFileReader
path = r"E:\python\Real Python\Real Python\Course materials\Chapter 8\Practice files"
inputFileName = os.path.join(path,"Pride and Prejudice.pdf")
inputFile = PdfFileReader(file(inputFileName,"rb"))
print "Number of pages:", inputFile.getNumPages()
print "Title:", inputFile.getDocumentInfo().title
现在,当我运行这段代码时,出现了一个错误:
'module' object has no attribute 'Number'
我截了一张运行上述代码后整个输出的截图,包括错误信息。请看看,告诉我哪里出问题了?
在代码中使用了 import decimal
之后,我又遇到了一些错误。所以,我又截了一张完整的截图,附在这里。

1 个回答
0
pyPdf现在改名为pypdf
,而且有一些类和方法的名字也进行了更改。我是pypdf和PyPDF2的维护者。
另一个变化是我们不再使用decimal
这个东西了。现在我们使用内置的float
。所以在以后的pypdf
版本中,这个错误就不会出现了。