Python3.7版本的新增功能。
正在尝试使用pypdf2
,但我有一个无法自行修复的错误:
我的命令:
pdfFile2 = open(r"C:\Users\Luca\Desktop\python\tutorial\doc2.pdf", "wb") # w=write, r=read, b=binary
writer1 = pyPDF2.PdfFileWriter()
错误:
Traceback (most recent call last):
File "C:/Users/Luca/Desktop/python/tutorial/tutorial.py", line 8, in <module>
writer1 = pyPDF2.PdfFileWriter()
NameError: name 'pyPDF2' is not defined
我已经安装了pypdf2
库,但是我不能继续,我该如何修复它?在
这很可能是因为您的示例在代码的第二行使用了
pyPDF2
(smallp
),而不是PyPDF2
(大写P
)。在第一步: PyPDF2是一个纯Python包,因此可以使用pip安装它(假设pip位于系统路径中):
第二步: 一旦你安装了这些软件包。 您可以从该库导入特定的包,如PdfFileReader和PdfFileWriter。在
第三步: 最后,可以直接实例化该模块对象
#供读者阅读
#用于写入
文件:https://pythonhosted.org/PyPDF2/PdfFileWriter.html
相关问题 更多 >
编程相关推荐