import subprocess
while True:
subprocess.call(input("> "), shell=True)
比方说,当我运行
adb shell settings get system volume_music_speaker
时,如何获取返回值并存储它,比如说,它是最大音量,所以返回值将是14。我已经尝试过
while True:
a = subprocess.call(input("> "), shell=True)
print(a)
但我总是得到 0。谢谢。
https://docs.python.org/3/library/subprocess.html#subprocess.PIPE
with subprocess.Popen(input("> "),
shell=True,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
) as your_process:
output, err = your_process.communicate()