一区二区三区在线-一区二区三区亚洲视频-一区二区三区亚洲-一区二区三区午夜-一区二区三区四区在线视频-一区二区三区四区在线免费观看

腳本之家,腳本語言編程技術及教程分享平臺!
分類導航

Python|VBS|Ruby|Lua|perl|VBA|Golang|PowerShell|Erlang|autoit|Dos|bat|

服務器之家 - 腳本之家 - Python - 用python解壓分析jar包實例

用python解壓分析jar包實例

2020-04-19 11:09海峰-清歡 Python

今天小編就為大家分享一篇用python解壓分析jar包實例,具有很好的參考價值,希望對大家有所幫助。一起跟隨小編過來看看吧

寫這個玩意的背景:在u8多渠道打包里,需要分析jar包,并把里面的文件按目錄和類型分別放在root和assets文件夾里,之前師兄都是手動解壓,一個一個文件夾找文件,效率比較低,剛好最近手上的android項目已經做完了,就決定寫一個自動化分析jar文件并復制粘貼到指定文件夾的腳本。

?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
# -*- 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包實例就是小編分享給大家的全部內容了,希望能給大家一個參考,也希望大家多多支持服務器之家。

原文鏈接:https://blog.csdn.net/u013692888/article/details/75011528

延伸 · 閱讀

精彩推薦
主站蜘蛛池模板: a级片在线播放 | 国产成人a∨麻豆精品 | xx18美女美国 | 国产无套在线播放 | ysl蜜桃色成人麻豆 youwu在线影院 | 欧洲肥女大肥臀 | cos美女被黄网站 | 国产精品久久久久久久久99热 | 国产精品久久国产精品99盘 | 九九99热久久999精品 | 日韩欧美亚洲每日更新网 | xxxx野外性xxxx| 隔壁老王国产在线精品 | 九九热视频免费 | 99久女女精品视频在线观看 | 亚洲精品视频久久 | 456在线观看 | 共妻高h | 九九精品视频在线观看九九 | 免费欧美一级 | 韩国最新理论片奇忧影院 | 欧美国产日本精品一区二区三区 | 4455永久在线视频观看 | 欧洲久久 | 亚洲 日本 中文字幕 制服 | 亚洲欧美日韩另类在线 | 全色黄大色黄大片爽一次 | 97porm自拍视频区原创 | 人与动人物性行为zozo共患病 | 欧美男同猛男 videos 同性 | 毛片视频在线免费观看 | 国产在线观看人成激情视频 | 亚洲国产精品综合福利专区 | 青苹果乐园影院在线播放 | 欧美午夜视频一区二区三区 | www.青青操 | 日韩精品一区二区三区中文字幕 | bl放荡受np双性 | 情欲满载2012美国dvd | 国产精品久久久久久久久久久威 | 精品无码久久久久久久久 |