您好,登錄后才能下訂單哦!
小編給大家分享一下怎么用python解壓分析jar包,希望大家閱讀完這篇文章之后都有所收獲,下面讓我們一起去探討吧!
Python主要應用于:1、Web開發;2、數據科學研究;3、網絡爬蟲;4、嵌入式應用開發;5、游戲開發;6、桌面應用開發。
代碼如下:
# -*- coding: utf-8 -*- import os import shutil import zipfile count = 1 def getSumDir(): sumfilelist = os.listdir(os.getcwd()) for dir in sumfilelist: if ".idea" not in dir: classify(dir) def getlibDir(): sumfilelist = os.listdir(os.getcwd()) for dir in sumfilelist: if "libs" in dir: jieyajar(dir) def jieyajar(dir): files = os.listdir(dir) for jars in files: if "jar" in jars: zfile = zipfile.ZipFile('libs/' + jars, 'r') if not os.path.exists(os.getcwd() + '/jarlog/' + jars): os.makedirs(os.getcwd() + '/jarlog/' + jars) zfile.extractall(os.getcwd() + '/jarlog/' + jars) if not os.path.exists(os.getcwd() + '/jars/'): os.makedirs(os.getcwd() + '/jars/') zfile.extractall(os.getcwd() + '/jars/') zfile.close for file in os.listdir(os.getcwd()): if "jars" in file: classify(file) # def classify(path): # if os.path.isfile(path): # if ".class" not in path: # if "assets" in os.path.dirname(path): # if not os.path.exists(os.path.dirname(os.getcwd()) + '/assets/' + os.path.dirname(path)): # os.makedirs(os.path.dirname(os.getcwd()) + '/assets/' + os.path.dirname(path)) # shutil.copy(path, os.path.dirname(os.getcwd()) + '/assets/' + os.path.dirname(path)) # else: # if not os.path.exists(os.path.dirname(os.getcwd())+'/root/'+os.path.dirname(path)): # os.makedirs(os.path.dirname(os.getcwd())+'/root/'+os.path.dirname(path)) # shutil.copy(path,os.path.dirname(os.getcwd())+'/root/'+os.path.dirname(path)) # else : # list = os.listdir(path) # for dir in list: # classify(path+"/"+dir) def classify(path): global count if os.path.isfile(path): if ".class" not in path: if not os.path.exists(os.getcwd() + '/root/' + os.path.dirname(path)): os.makedirs(os.getcwd() + '/root/' + os.path.dirname(path)) shutil.copy(path, os.getcwd() + '/root/' + os.path.dirname(path)) else: if 'assets' in path and count == 1: count = count + 1 shutil.copytree(os.getcwd()+'/'+path, os.getcwd() + '/assets') elif 'META-INF' not in path: list = os.listdir(path) for dir in list: classify(path + "/" + dir) # getSumDir() getlibDir()
看完了這篇文章,相信你對“怎么用python解壓分析jar包”有了一定的了解,如果想了解更多相關知識,歡迎關注億速云行業資訊頻道,感謝各位的閱讀!
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。