pyPdf错误无效参数

ksc*_*ler 5 python pdf file pypdf invalid-argument

我实际上是使用pyPdf来打开,读取和写入PDF文件的内容.

为此我使用这些代码行:

from pyPdf import PdfFileWriter, PdfFileReader

pdf = PdfFileReader(file("/myPdfFile.pdf", "w+b"))
content = pdf.getPage(1).extractText()
print content
Run Code Online (Sandbox Code Playgroud)

但它返回给我这个错误,我不明白为什么

File "/usr/local/lib/python2.6/dist-packages/pyPdf/pdf.py", line 374, in __init__
    self.read(stream)
File "/usr/local/lib/python2.6/dist-packages/pyPdf/pdf.py", line 702, in read
    stream.seek(-1, 2)
IOError: [Errno 22] Invalid argument
Run Code Online (Sandbox Code Playgroud)

有人可以帮帮我吗?

MRA*_*RAB 1

正如 Python 文档中所述,该模式'w+b'打开文件并将其截断为 0 字节,而'r+b'打开文件时不截断。