我正在研究 Flightgear,我想要一种从 Python 脚本针对特定飞机启动/Applications/FlightGear.app 的方法,但它不接受额外参数。
这个有效:
os.system("open /Applications/FlightGear.app/Contents/MacOS/fgfs")
这样做,但不会选择飞机...我已经尝试过在“飞机”前面使用和不使用连字符。
os.system("open /Applications/FlightGear.app/Contents/MacOS/fgfs --args aircraft=777-200ER")
供引用,
(来源:flightgear.org)
请您参考如下方法:
是这样的。有时,某些论点必须结合起来,具体取决于它们之间的关系。
import subprocess
p = subprocess.Popen(['open', '/Applications/FlightGear.app/Contents/MacOS/fgfs', '--args', 'aircraft=777-200ER'])
if p.wait() != 0:
raise EnvironmentError()
这是基本信息,只需在 Google 中搜索“python run command”即可找到。 SO 不仅仅是懒人的工具。
