我试图在命令提示符中使用os.system命令。我唯一有困难的部分是:
os.system('taskkill /s %s /u CORP\Administrator /p CLARiiON! /pid AxAuto.exe'%(connection[i]))变量connection[i]只是同一网络上远程计算机的IP地址。我可以在本地直接从命令提示符运行这个命令,只需直接输入IP,而且我知道它是可以工作的,但是通过Python以这种格式运行命令">此时是出乎意料的“。我是不是在这一行代码中犯了一个愚蠢的格式化错误?这个错误可以在下面看到:

编辑:我也被告知要使用Subprocess模块。我试了下面的片段:
command="taskkill /s %s /u CORP\Administrator /p CLARiiON! /im AxAuto.exe"%(connection[i]))
subprocess.Popen(command, stdout= subprocess.PIPE, stdin = subprocess.PIPE, stderr=subprocess.PIPE)它不会在脚本中失败,但也不会扼杀进程。
发布于 2015-04-23 13:57:18
尝试下面的代码:
from subprocess import call
call(['taskkill', '/s', connection[i], '/u', 'CORP\Administrator', '/py',
'CLARiiON!', '/pid', 'AxAuto.exe'])https://stackoverflow.com/questions/29824535
复制相似问题