PyPDF2 IOError:[Errno 22]PyPdfFileReader Python 3.9.5上的参数无效
目标=解密文件 尝试使用PyPDF2模块来完成此任务。获取以下错误:PyPDF2 IOError:[Errno 22]PyPdfFileReader Python 3.9.5上的参数无效,python,file,pypdf2,Python,File,Pypdf2,目标=解密文件 尝试使用PyPDF2模块来完成此任务。获取以下错误: File "c:\Users\Niveet\Documents\Python Projects\Audio books\x.py", line 6, in <module> reader = pdf.PdfFileReader(f) File "C:\Users\Niveet\AppData\Local\Programs\Python\Python39\lib\site
File "c:\Users\Niveet\Documents\Python Projects\Audio books\x.py", line 6, in <module>
reader = pdf.PdfFileReader(f)
File "C:\Users\Niveet\AppData\Local\Programs\Python\Python39\lib\site-packages\PyPDF2\pdf.py", line 1084, in __init__
self.read(stream)
File "C:\Users\Niveet\AppData\Local\Programs\Python\Python39\lib\site-packages\PyPDF2\pdf.py", line 1689, in read
stream.seek(-1, 2)
OSError: [Errno 22] Invalid argument
import PyPDF2 as pdf
password = 'ABC123'
with open('Audio books\\resources\\The-War-of-the-Worlds-protected.pdf', 'rb') as f:
#Creating Reader
reader = pdf.PdfFileReader(f)
if reader.isEncrypted:
success = reader.decrypt(password)
if success:
print('PDF is successfully decrypted')
else:
print('PDF decryption failed')