安装
$ pip install unrar
解压
from unrar import rarfile# 源码:/matiasb/python-unrar# 下载UnRAR.dll /rar_add.htm# 配置UnRAR.dll位置# 在系统变量里配置# UNRAR_LIB_PATH = C:\Program Files (x86)\UnrarDLL\x64\UnRAR64.dllfilename = 'rar压缩包路径'extract_path = '解压路径'fp = rarfile.RarFile(filename)for pwd in range(0, 10000):# 左对齐,不足补0pwd = "{0:0>4}".format(pwd)try:fp.extractall(pwd=pwd, path=extract_path)print('Success:', pwd)breakexcept Exception:print(pwd)pass