簡體   English   中英

使用python中的參數運行外部程序(可執行文件)

[英]Running an external program (executable) with parameters in python

我正在嘗試使命令行程序自動化。

exe文件需要一個參數才能運行。 例如:

ztac.exe <mode> (其中模式選項為safenormaldebug )。

要以調試模式運行,我只需在命令行中輸入以下內容:

C:\\source>ztac debug

如何在將不同模式作為輸入的同時編寫Python程序來運行此ztac.exe文件?

program = 'ztac.exe'
arguments = ('safe', 'normal', 'debug')
argument = raw_input('Enter your argument: ')
if argument in arguments:
  subprocess.call([program, argument])
else:
  print('Illegal Argument')

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM