美文网首页
python获取手机包名并遍历

python获取手机包名并遍历

作者: 我爱吃豆芽 | 来源:发表于2018-12-24 17:13 被阅读37次
# -*- coding: UTF-8 -*-
import  os
import time
from  uiautomator import device as d
os.system('adb devices')
a = os.popen("adb shell pm list package") #获取手机上所有的包名
for i in a:
    i = i.lstrip('package').lstrip(":").strip()#取出每一个包
    os.system( "adb shell monkey -p "+i+" -c android.intent.category.LAUNCHER 1") #将包名拼接到命令中
    time.sleep(3)
    d.press.home()

相关文章

网友评论

      本文标题:python获取手机包名并遍历

      本文链接:https://www.haomeiwen.com/subject/ltwzkqtx.html