之前已经讲过Python基础知识,怎么样在Python中写出脚本。今天我们继续学习python怎么写脚本来执行adb命令。
Python的os包中,可以通过os.system 或 os.popen来实现本地adb命令的调用。
建立下图的文件结构:
app文件夹中放上要执行安装的apk,Python的代码如下:
<p style="line-height: 1.75em"><span>import os import time flies = os.listdir("app"); for ff in flies: print "adb install -r " + ff text = os.popen("adb install -r app/" + ff) time.sleep(2) print text.read();<br></span></p>
www#gaodaima.com来源gao@dai!ma.com搞$代^码网搞代码
是不是步骤简单容易操作,大家可以上手尝试一下。更多python实用知识,点击进入云海天Python教程网
来源:搞代码网:原文地址:https://www.gaodaima.com