【发布时间】:2020-11-09 17:02:57
【问题描述】:
试图弄清楚如何做到这一点:
command = f"adb -s {i} shell"
proc = Popen(command, stdin=PIPE, stdout=PIPE)
out, err = proc.communicate(f'dumpsys package {app_name} | grep version'.encode('utf-8'))
但是在这个:
command = f"adb -s {i} shell"
proc = run(command, stdin=PIPE, stdout=PIPE, shell=True)
out, err = run(f'dumpsys package {app_name} | grep version', shell=True, text=True, stdin=proc.stdout )
这个想法是创建一个需要某种输入的命令(例如(进入 shell)),然后将另一个命令插入到 shell。 我找到了一种在线交流的方法,但我想知道如何使用 run() func 来做到这一点。 谢谢!
【问题讨论】:
-
请阅读PEP-8。
=周围应仅在赋值中使用空格,而不是关键字参数。
标签: python python-3.x shell cmd adb