Python 如何解压缩带密码的RAR文件

import rarfile

data_file_path = ‘C:\\data_folder\\file_name.rar’
extracted_folder = ‘C:\\TEMP’
rf
= rarfile.RarFile(data_file_path) # 待解压文件
password = '123456'
rf.setpassword(pwd=password)
rf.extractall(extracted_folder)

如果出现报错: 

rarfile.RarCannotExec: Cannot find working tool.

把winrar的目录设置到环境变量,重启PyCharm 就可以解决。 

 

posted on 2022-01-07 13:48  m2land  阅读(1347)  评论(0编辑  收藏  举报

导航