我尝试打开一个 pdf 文件,该文件使用已安装的 PyPDF2 模块下载,如下所示:
import PyPDF2
pdfFileObj = open('ssopenpyxl-readthedocs-io-en-latest.pdf', 'rb')
pdfReader = PyPDF2.PdfFileReader(pdfFileObj)
pdfReader.numPages
它给了我一个 filenotfound 错误消息:
FileNotFoundError Traceback (most recent call last)
<ipython-input-10-243eb92ac6df> in <module>
1 import PyPDF2
----> 2 pdfFileObj = open('ssopenpyxl-readthedocs-io-en-latest.pdf', 'rb')
3 pdfReader = PyPDF2.PdfFileReader(pdfFileObj)
4 pdfReader.numPages
FileNotFoundError: [Errno 2] No such file or directory: 'ssopenpyxl-readthedocs-io-en-latest.pdf