我正试图编写一个Python,将我的Mac的卷级别作为我可以操作的变量:几乎完全是this。但是,当我尝试从shell运行相同的命令时,我似乎无法将变量设置为一个新值。
>>> ovol = "dummy"
>>> call(['osascript', '-e', 'set ovol to output volume of (get volume settings)'])
88 #this is correct
0 #not sure where this comes from
>>> ovol
'dummy'发布于 2016-01-31 21:18:59
这里是您使用check_output的地方。
from subprocess import check_output
ovol = check_output(['osascript', '-e', 'get volume settings'])
print ovol现在,您只需解析从“get卷设置”返回的字符串。
https://stackoverflow.com/questions/35119506
复制相似问题