分享

Python学习遇到的问题3

 lunabook 2022-12-29 发布于湖北

继续《Automate the boring stuff with python》。学到pdf和word文档处理章节,最后的练习题又遇到困难,向各位求助。这里吐槽一下,国内好像没有对零基础学员特别友好的提问平台,我感觉需要找人带着学。哪里有付费咨询的地方,也请各位告知一下。

Using the os.walk() function from Chapter 9, write a script that will go through every PDF in a folder (and its subfolders) and encrypt the PDFs using a password provided on the command line. Save each encrypted PDF with an _encrypted.pdf suffix added to the original filename. Before deleting the original file, have the program attempt to read and decrypt the file to ensure that it was encrypted correctly. Then, write a program that finds all encrypted PDFs in a folder (and its subfolders) and creates a decrypted copy of the PDF using a provided password. If the password is incorrect, the program should print a message to the user and continue to the next PDF.

我写的代码和实际的效果如下图:部分已经实现加密操作了。但子文件夹内的文件没有被加密。

报错如下:

我理解的大致意思就是由于子文件夹的存在,在当前文件夹没找到这个文件,但是在pdfFiles变量里面存在这个文件名,实际打开的时候该文件夹不存在这个文件。但我不知道怎么解决。请各位帮忙指点一下,谢谢。

    转藏 分享 献花(0

    0条评论

    发表

    请遵守用户 评论公约

    类似文章 更多