python3怎么打开7z压缩文件_python使用7z解压apk包的方法

本文介绍如何在Python3中通过shell调用7z工具解压apk文件,包括定义运行shell命令的函数及解压操作示例。
摘要由CSDN通过智能技术生成

本文实例讲述了python使用7z解压apk包的方法。分享给大家供大家参考。具体如下:

这段代码通过shell调用7z对apk包进行解压缩 def run_shell(command, mayFreeze=False):

def check_retcode(retcode, cmd):

if 0 != retcode:

print >> sys.stderr, 'err executing ' + cmd + ':', retcode

sys.exit(retcode)

def read_close(f):

f.seek(0)

d = f.read()

f.close()

return d

#print >> sys.stderr, '-- Executing', command

if mayFreeze:

tempout, temperr = tempfile.TemporaryFile(), tempfile.TemporaryFile()

#open(os.devnull, 'w')

p = subprocess.Popen(command, stdout=tempout, stderr=temperr)

p.wait()

output, errout = read_close(tempout), read_close(temperr)

else:

p=subprocess.Popen(command,stdout=subprocess.PIPE,stderr=subprocess.PIPE)

output = p.stdout

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值