如何在Python中的文件流中添加EOF?

问题描述 投票:0回答:1

我想用Python和pypdf库阅读PDF文件。有些 PDF 文件没有 EOF,脚本会抛出异常。

from pypdf import PdfReader

reader = PdfReader(f)

如何在

f
IO流中添加b'%%EOF'来解决这个问题?

python pdf eof
1个回答
-3
投票

我没有 pdf 文件来测试它,但你不能做点什么吗:

try x

if returns exception, break

else, read the current page
© www.soinside.com 2019 - 2024. All rights reserved.