国产探花免费观看_亚洲丰满少妇自慰呻吟_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程序設計有所幫助。

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 沐川县| 留坝县| 客服| 新和县| 绍兴市| 石嘴山市| 河东区| 玛多县| 郑州市| 清镇市| 五莲县| 潮安县| 乃东县| 沐川县| 孟连| 乐山市| 沂水县| 宜良县| 南皮县| 淮南市| 中卫市| 陇川县| 潮州市| 鹰潭市| 商丘市| 肇东市| 贡山| 枝江市| 孟津县| 沈丘县| 右玉县| 平果县| 定远县| 克拉玛依市| 沂南县| 苏州市| 镶黄旗| 昌吉市| 大邑县| 莒南县| 都兰县|