项目中需要内置apk,部分apk需要提取so进行内置,有时候会碰到so文件超多的时候,最多达78个~,所以觉得需要写个脚本,自动生成文件路径,这样以后就方便了,闲话少说直接上代码.脚本名称是printPath.py.
代码如下:
#!/usr/bin/env python
# coding: utf-8
import os
import sys
txtname="ipad.txt"
if os.path.exists(txtname):
os.remove(txtname)
f=file(txtname,"a+")
dire="."
forward=raw_input("请输入 dst 路径: ")
afterward=raw_input("请输入 src 路径: ")
for root,dirs,files in os.walk(dire):
for file_single in files:
if file_single.endswith(".so"):
refile=dire[1:]
test="<file dst=\""+forward+"/"+refile+file_single+"\""+"\t"+"src =\""+afterward+"/"+refile+file_single+"\"/>"
result=test+'\n'
f.write(result)
print "路径已输出至ipad.txt,请拷贝!"
f.close()
用法是:
将apk解压后将printPath脚本放到so同级目录下,执行./printPath.py,记得给printPath.py加权限,我一般都是直接给777的权限,
chmod 777 printPath.py
路径会输出到ipad.txt中,进去复制一下就行了.
欢迎大家学习交流,^____^