Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/EmptyTag/139.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
PyPDF2 IOError:[Errno 22]PyPdfFileReader Python 3.9.5上的参数无效_Python_File_Pypdf2 - Fatal编程技术网

PyPDF2 IOError:[Errno 22]PyPdfFileReader Python 3.9.5上的参数无效

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

目标=解密文件 尝试使用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-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')