Python模块ADB的使用指南_笔记大全_设计学院 (python100.com)
pip install adb
Python 调用ADB_python 调用adb命令_实相实相的博客-CSDN博客
Python ADB.shell_command Examples, pyadb.ADB.shell_command Python Examples - HotExamples
# creates the ADB object
adb = ADB()
# IMPORTANT: You should supply the absolute path to ADB binary
if adb.set_adb_path('/usr/bin/adb') is True:
print("Version: %s" % adb.get_version())
else:
print("Check ADB binary path")
apps = adb.shell_command("pm list packages")
for app in apps:
path = adb.shell_command("pm path {}".format(app.split(':')[1]))
print("{}: {}".format(app, path))
python在adb shell环境下执行命令 - wztshine - 博客园 (cnblogs.com)
import subprocess
obj = subprocess.Popen('adb -s 8BHX1B399 shell', stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE,shell=True)
out,err = obj.communicate(input='cd /data/;ls;find . -type d'.encode()) # 通过communicate传递数据,返回(stdout,stderr)
print(out.decode())
import os
import subprocess
cmd = 'adb -s 8BHX1B399 shell "cd /data;ls"' # 将你要执行的子命令用引号写出来,命令间以';'分割
result = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True)
output, error = result.communicate(timeout=600)
print(output.decode())
Python 在Python中使用subprocess的communicate函数实现多个输入和输出|极客教程 (geek-docs.com)