python -apk 安装-卸载-渠道包
- Python3并将Python3添加到环境变量,配置要环境
2 USB连接好一台手机
3 将需要验证的apk拷贝到py 文件所在的文件夹下
具体代码如下:
import os
def install_apk():
# 获取当前文件所在的路径即InstallApk所在路径
current_path = os.path.abspath(".")
# 获取到当前路径下的所有文件
files = os.listdir(current_path)
# 循环遍历files
for file in files:
# 判断如果后缀为apk结尾的就执行命令安装
if file[len(file) - 3:len(file)] == “apk”:
# 添加 " 是为了避免file路径出现空格(百度其他人的建议)
cmd = “adb install -r " + “”” + file + “”"
os.system(cmd)
time.sleep(5) # 等待5秒,确认已经安装上apk
cmd = "adb uninstall ******* " # **** 为应用程序名称
# 卸载安装包
os.system(cmd)
install_apk()