该脚本的功能是卸载android手机中安装的所有第三方应用,主要是使用adb shell pm、adb uninstall 命令,所以使用的前提是需要配好adb的环境变量,下面上代码:
1 #!/usr/bin/env python 2 3 import os 4 5 def uninstall(): 6 os.popen("adb wait-for-device") 7 print "start uninstall..." 8 for packages in os.popen("adb shell pm list packages -3").readlines(): 9 packageName = packages.split(":")[-1].splitlines()[0] 10 os.popen("adb uninstall " + packageName) 11 print "uninstall " + packageName + " successed." 12 13 if __name__ == "__main__": 14 uninstall() 15 print " " 16 print "All the third-party applications uninstall successed."
时间: 2024-10-10 12:04:53