This example describes how Python uses 7z to unzip the APK package. Share to everyone for your reference. Specific as follows:
This code is extracted from the shell by invoking the 7z APK package
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 &G T;> 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.read () p.wait () Errout = P.stderr.read () p.stdout.close () P.stderr.close () #check_retcode ( P.returncode, command) return (Output.strip (), Errout.strip ()) #z7 is the full path to 7z.exe#at times and you have to encode t He command into Gbk/utf8run_shell (U ' {0}-y-o "{1}" {2} x "{3}" '. Format (Z7, TempDir, Icon, apk)] shutil.copy (U ' {0}/{1} '. for Mat (Tempdir,os.path.basename (icon)), Dst_path)
Hopefully this article will help you with Python programming.