用python解壓分析jar包實(shí)例
寫(xiě)這個(gè)玩意的背景:在u8多渠道打包里,需要分析jar包,并把里面的文件按目錄和類(lèi)型分別放在root和assets文件夾里,之前師兄都是手動(dòng)解壓,一個(gè)一個(gè)文件夾找文件,效率比較低,剛好最近手上的android項(xiàng)目已經(jīng)做完了,就決定寫(xiě)一個(gè)自動(dòng)化分析jar文件并復(fù)制粘貼到指定文件夾的腳本。
# -*- 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()
嗯,主要就是對(duì)文件夾和文件的操作。。
以上這篇用python解壓分析jar包實(shí)例就是小編分享給大家的全部?jī)?nèi)容了,希望能給大家一個(gè)參考,也希望大家多多支持腳本之家。
- Python爬蟲(chóng)逆向分析某云音樂(lè)加密參數(shù)的實(shí)例分析
- Python調(diào)用jar包方法實(shí)現(xiàn)過(guò)程解析
- Python使用jpype模塊調(diào)用jar包過(guò)程解析
- Python代碼一鍵轉(zhuǎn)Jar包及Java調(diào)用Python新姿勢(shì)
- python如何使用jt400.jar包代碼實(shí)例
- 利用python腳本如何簡(jiǎn)化jar操作命令
- Python3 使用cookiejar管理cookie的方法
- python調(diào)用java的jar包方法
- Java實(shí)現(xiàn)的執(zhí)行python腳本工具類(lèi)示例【使用jython.jar】
- 將Python代碼打包為jar軟件的簡(jiǎn)單方法
- python 逆向爬蟲(chóng)正確調(diào)用 JAR 加密邏輯
相關(guān)文章
YOLOv5車(chē)牌識(shí)別實(shí)戰(zhàn)教程(七)實(shí)時(shí)監(jiān)控與分析
這篇文章主要介紹了YOLOv5車(chē)牌識(shí)別實(shí)戰(zhàn)教程(七)實(shí)時(shí)監(jiān)控與分析,在這個(gè)教程中,我們將一步步教你如何使用YOLOv5進(jìn)行車(chē)牌識(shí)別,幫助你快速掌握YOLOv5車(chē)牌識(shí)別技能,需要的朋友可以參考下2023-04-04
python matplotlib實(shí)現(xiàn)雙Y軸的實(shí)例
今天小編就為大家分享一篇python matplotlib實(shí)現(xiàn)雙Y軸的實(shí)例,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過(guò)來(lái)看看吧2019-02-02
對(duì)Pycharm創(chuàng)建py文件時(shí)自定義頭部模板的方法詳解
今天小編就為大家分享一篇對(duì)Pycharm創(chuàng)建py文件時(shí)自定義頭部模板的方法詳解,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過(guò)來(lái)看看吧2019-02-02
python內(nèi)置模塊datetime.timedelta計(jì)算時(shí)間間隔示例代碼
Python的datetime模塊提供了處理日期和時(shí)間的功能,包括datetime.date、datetime.time、datetime.datetime、datetime.timedelta等類(lèi),timedelta用于表示時(shí)間間隔,支持日期和時(shí)間的加減運(yùn)算,文中給出了詳細(xì)的代碼示例,需要的朋友可以參考下2025-04-04
詳解python如何通過(guò)numpy數(shù)組處理圖像
Numpy?是?Python?中科學(xué)計(jì)算的核心庫(kù),NumPy?這個(gè)詞來(lái)源于?Numerical?和?Python?兩個(gè)單詞。它提供了一個(gè)高性能的多維數(shù)組對(duì)象,以及大量的庫(kù)函數(shù)和操作,可以幫助程序員輕松地進(jìn)行數(shù)值計(jì)算,廣泛應(yīng)用于機(jī)器學(xué)習(xí)模型、圖像處理和計(jì)算機(jī)圖形學(xué)、數(shù)學(xué)任務(wù)等領(lǐng)域2022-03-03
Python爬蟲(chóng)實(shí)戰(zhàn)之虎牙視頻爬取附源碼
讀萬(wàn)卷書(shū)不如行萬(wàn)里路,學(xué)的扎不扎實(shí)要通過(guò)實(shí)戰(zhàn)才能看出來(lái),本篇文章手把手帶你爬取虎牙短視頻數(shù)據(jù),大家可以在實(shí)戰(zhàn)過(guò)程中查缺補(bǔ)漏,加深學(xué)習(xí)2021-10-10
基于Python實(shí)現(xiàn)一個(gè)春節(jié)倒計(jì)時(shí)腳本
春節(jié)即將到來(lái),本文將為大家介紹一個(gè)通過(guò)Python實(shí)現(xiàn)的春節(jié)倒計(jì)時(shí)腳本,文中的示例代碼簡(jiǎn)潔易懂,感興趣的小伙伴可以自己動(dòng)手嘗試一下2022-01-01
python中對(duì)開(kāi)區(qū)間和閉區(qū)間的理解
這篇文章主要介紹了python中對(duì)開(kāi)區(qū)間和閉區(qū)間的理解,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。如有錯(cuò)誤或未考慮完全的地方,望不吝賜教2022-07-07
selenium+headless chrome爬蟲(chóng)的實(shí)現(xiàn)示例
這篇文章主要介紹了selenium+headless chrome爬蟲(chóng)的實(shí)現(xiàn)示例,文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)學(xué)習(xí)吧2021-01-01

