import os
system = os.system("adb shell su -c 'cd data/data/com.xxx.xxx/xxx ; ls'")
复制代码
su 表示拿到管理员权限python
result = os.popen("adb shell su -c 'cd data/data/com.xxx.xxx/xxx ; ls'")
res = result.read()
for line in res.splitlines():
print(line)
复制代码
import subprocess
# 这个也能够用,可是不知道怎么拿到su权限
p1 = subprocess.Popen('adb shell cd data&&cd data&&ls |grep com', stdout=subprocess.PIPE,
stderr=subprocess.PIPE )
print(p1.stdout.read())
复制代码
参考了 python获取命令行输出结果shell