[英]Running an external program (executable) with parameters in python
我正在嘗試使命令行程序自動化。
exe
文件需要一個參數才能運行。 例如:
ztac.exe <mode>
(其中模式選項為safe
, normal
或debug
)。
要以調試模式運行,我只需在命令行中輸入以下內容:
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.