话不多说,直接上代码:
1、指定一个存放apk的本地路径
2、插上打开了usb调试的手机
#!/usr/bin/evn python
# -*- coding: utf-8 -*-
#jojo_xia
import os
import re
class GetApp:
def __init__(self):
pass
def get_apkPath(self, path):
list_apk = []
for file in os.listdir(path):
file_path = os.path.join(path, file)
list_apk.append(file_path)
return list_apk
def get_devices(self):
rst = os.popen("adb devices").read()
devices = re.findall(r'(.*?)\s+device',rst)
if len(devices) > 1:
deviceIds = devices[1:]
return deviceIds
else:
print('没有找到手机,请检查')
return None
def install_apk(self, deviceIds, list_apk):
for d in range(len(deviceIds)):
for i in list_apk:
apk_name = i.split("\\")[-1]
cmd_