我正在尝试编写一个小程序,在多台计算机上连续多次运行一个可执行文件(delprof2.exe)。我已经用中的PC名称创建了三个列表,并且基本上需要使用开关/c:itroom01(例如)为列表中的每台机器运行可执行文件,但是我不知道如何对机器名称部分进行编码-您可以从reply=1部分看到我已经做了多少。你知道吗
参见代码:
import os
import subprocess
itroom = ["itroom01", "itroom02", "itroom03"]
second = ["2nditroom01", "2nditroom02", "2nditroom03"]
csupport = ["csupport-m30", "csupport-m31", "csupport-m32"]
print "Which room's PCs do you want to clear out?"
print "\t(1) = ITRoom"
print "\t(2) = 2nd ITRoom"
print "\t(3) = Curriculum Support"
reply = input("Enter 1, 2 or 3: ")
if reply == 1:
for item in itroom:
subprocess.call(['c:\delprof2\DelProf2.exe /l /c:'%itroom])
raw_input("Press return to continue...")
elif reply == 2:
for item in second:
subprocess.call("c:\delprof2\DelProf2.exe /l")
raw_input("Press return to continue...")
elif reply == 3:
for item in csupport:
subprocess.call("c:\delprof2\DelProf2.exe /l")
raw_input("Press return to continue...")
else:
print "invalid response"
raw_input("Press return to continue...")
任何帮助都将不胜感激!你知道吗
谢谢你, 克里斯。你知道吗
你的问题是字符串格式。阅读the tutorial了解如何进行基本格式化。你知道吗
如果所有项都是字符串,则可以将字符串连接起来(
+
):注意:如果希望所有子进程同时运行,则可以直接使用
Popen
:相关问题 更多 >
编程相关推荐