[英]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.