将Shell ADB与Python连接
我正在尝试从ADB访问设备,但它一直在加载且无法访问
功能:
def get_device():
outuput = subprocess.Popen(["adb.exe" , "devices" , "-l" ] ,stdout=subprocess.PIPE)
outuput = str(outuput.communicate()[0])
devices = [x.split() for _ , x in enumerate(outuput.split("\\n")) if "model:" in x and not _ == 0 ]
return devices
我尝试了:
devices = get_device()[0]
adb_ouput = check_output(["adb", "-s" , devices, "shell"] , shell=True, text=True)
print(adb_ouput)
我也尝试过:
p = subprocess.Popen(["adb", "-s" , devices, "shell"], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
out, err = p.communicate()
print(out)
但是它保持了加载,并且不会继续
I am trying to access a device from adb but it keeps loading and does not access
function:
def get_device():
outuput = subprocess.Popen(["adb.exe" , "devices" , "-l" ] ,stdout=subprocess.PIPE)
outuput = str(outuput.communicate()[0])
devices = [x.split() for _ , x in enumerate(outuput.split("\\n")) if "model:" in x and not _ == 0 ]
return devices
I've tried this:
devices = get_device()[0]
adb_ouput = check_output(["adb", "-s" , devices, "shell"] , shell=True, text=True)
print(adb_ouput)
I also tried:
p = subprocess.Popen(["adb", "-s" , devices, "shell"], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
out, err = p.communicate()
print(out)
but it stays loading and does not continue
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如评论中提到的那样,有许多库这样做。其中之一是 androidViewClient/culebra 。
在执行了尝试的简单步骤之后,您可能还需要许多其他事情。
There are many libraries doing that as mentioned in comments. One of them is AndroidViewClient/culebra.
Which does many other things as well which you may need after doing the simple steps you have tried.