Python脚本从.txt文件接收输入问题

时间:2014-05-19 15:39:39

标签: python-2.7

我试图编写一个小脚本,从外部.txt文件读取pc名称,然后针对每个脚本运行命令。

我的代码:

import subprocess

listCommand = ("c:\delprof2\DelProf2.exe /l /c:")

userID = raw_input("Please enter the name of the ID to remove: ")

with open (r"pc-list.txt") as file:
    lines = []
    for line in file:
        subprocess.Popen(listCommand + line + " /id:" + userID).wait()
        raw_input("Press return to continue...")

.txt文件的内容:

itroom01
itroom02
itroom03
itroom04
itroom05

当我来运行脚本时,它似乎不喜欢文件的输入。它不知道线的末端是正确的。是否有任何人可以看到看起来不对劲?也许我需要以不同的方式格式化txt文件..?

任何想法都会受到赞赏,

克里斯。

(Python 2.7)

0 个答案:

没有答案
相关问题