首页 > 代码库 > 批量安装/卸载手机apk--python语言

批量安装/卸载手机apk--python语言

import os
import time

filedir = "D:\\app"

def install():
files = os.listdir(filedir)
for file in files:
text = os.popen("adb install -r D:\\app\\"+ file)
print "adb install "+file
print text.read()


def uninstall():
for packages in os.popen("adb shell pm list package -3").readlines():
packageName = packages.split(":")[-1].splitlines()[0]
if "google" not in packageName:
text = os.popen("adb uninstall " + packageName)
print "uninstall "+ packageName
print text.read()

def main():
install()
uninstall()


if __name__ == ‘__main__‘:
main()

批量安装/卸载手机apk--python语言