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 就可以解决。
标签:rarfile,Python,解压缩,extracted,rf,RAR,file,folder,data 来源: https://www.cnblogs.com/DotNetNuke/p/15774745.html