国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 編程 > Python > 正文

python使用7z解壓apk包的方法

2020-01-04 19:29:34
字體:
來源:轉載
供稿:網友

這篇文章主要介紹了python使用7z解壓apk包的方法,涉及Python的shell命令調用技巧,非常具有實用價值,需要的朋友可以參考下

本文實例講述了python使用7z解壓apk包的方法。分享給大家供大家參考。具體如下:

這段代碼通過shell調用7z對apk包進行解壓縮

 

 
  1. def run_shell(command, mayFreeze=False): 
  2. def check_retcode(retcode, cmd): 
  3. if 0 != retcode: 
  4. print >> sys.stderr, 'err executing ' + cmd + ':', retcode 
  5. sys.exit(retcode) 
  6. def read_close(f): 
  7. f.seek(0
  8. d = f.read() 
  9. f.close() 
  10. return d 
  11. #print >> sys.stderr, '-- Executing', command 
  12. if mayFreeze: 
  13. tempout, temperr = tempfile.TemporaryFile(), tempfile.TemporaryFile() 
  14. #open(os.devnull, 'w') 
  15. p = subprocess.Popen(command, stdout=tempout, stderr=temperr) 
  16. p.wait() 
  17. output, errout = read_close(tempout), read_close(temperr) 
  18. else
  19. p=subprocess.Popen(command,stdout=subprocess.PIPE,stderr=subprocess.PIPE) 
  20. output = p.stdout.read() 
  21. p.wait() 
  22. errout = p.stderr.read() 
  23. p.stdout.close() 
  24. p.stderr.close() 
  25. #check_retcode(p.returncode, command) 
  26. return (output.strip(), errout.strip()) 
  27. #z7 is the full path to 7z.exe 
  28. #at times you have to encode the command into GBK/UTF8 
  29. run_shell(u'{0} -y -o"{1}" {2} x "{3}"'.format(z7, tempdir, icon, apk)) 
  30. shutil.copy(u'{0}/{1}'.format(tempdir,os.path.basename(icon)),dst_path) 

希望本文所述對大家的Python程序設計有所幫助。

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 周口市| 东山县| 禄劝| 葫芦岛市| 友谊县| 于田县| 定襄县| 揭东县| 行唐县| 河津市| 大名县| 梁河县| 德令哈市| 苏尼特左旗| 瑞安市| 玛多县| 竹溪县| 武宁县| 日喀则市| 肇东市| 县级市| 桓台县| 镇安县| 宝应县| 洛宁县| 华池县| 高邑县| 玛曲县| 礼泉县| 修文县| 元谋县| 鲁甸县| 衡山县| 舞阳县| 宿松县| 阳信县| 甘洛县| 格尔木市| 贵德县| 南溪县| 肇庆市|