批量解压 rar (带密码) -- 自己写的 python 小工具

import os
import threading 

def extract(file):
  os.system("unrar x -y -p'{passwd}'  '{filename}' ".format(passwd='w5GrlKpEXhbO9&utD!6KWWrFKmjI@XW3',filename=it))

def getPaths(path):
  res = os.listdir(path)
  return [ os.path.join(os.getcwd(),it) for it in res if it.endswith('.rar')]

if __name__=='__main__':
  try:
    #默认当前路径索引rar文件
    for it in getPaths('./'):
      print('*****file****',it)
      t1 = threading.Thread(target=extract,args=(it, ))
      t1.start()
      t1.join()
    
  except:
    print ("Error: 无法启动线程")

 

posted @ 2021-10-14 10:23  酒觉  阅读(277)  评论(0编辑  收藏  举报