[英]Executing and reading the response from a command line application using python
[英]Executing command line command from Python
我知道人们已经解决了类似的问题,但是我仍然感到困惑。
我想在Windows命令行中使用Python执行命令“ Inventory.bat rap.t00z.awp236pgrbf00.grib2 rap.t00z.awp236pgrbf00 LoLa 25 48 33 -122 -83”。
我当前的Python脚本是:
import subprocess
subprocess.check_output(['Inventory.bat', 'rap.t00z.awp236pgrbf00.grib2 rap.t00z.awp236pgrbf00', 'LoLa', '25', '48', '33', '-122', '-83'])
当由Python执行时,这不起作用。 我想念什么?
谢谢你的帮助!
在Windows下, .bat
文件由cmd
shell执行。 要使用shell,您必须在subprocess
函数中包含shell=True
选项。
subprocess.check_output(['Inventory.bat', 'rap.t00z.awp236pgrbf00.grib2 rap.t00z.awp236pgrbf00', 'LoLa', '25', '48', '33', '-122', '-83'], shell=True)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.