实际上,我正在使用pyPdf打开、读取和写入PDF文件的内容。
为此,我使用以下几行代码:
from pyPdf import PdfFileWriter, PdfFileReader
pdf = PdfFileReader(file("/myPdfFile.pdf", "w+b"))
content = pdf.getPage(1).extractText()
print content但是它返回了这个错误,我不明白为什么
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有人能帮我吗?
发布于 2012-05-23 01:24:39
正如Python文档中所说,'w+b'模式打开文件并将其截断为0字节,而'r+b'打开文件时不会截断。
https://stackoverflow.com/questions/10706778
复制相似问题