当我关闭一个文件对象时,我得到一个返回码 2 而不是“无”。
output = []
cmd = cmd.lstrip()
if cmd.startswith('"') == True and cmd.count('"') > 2:
found = re.search(r'^".*?"', cmd)
if found != None:
shortName = win32api.GetShortPathName(found.group(0).replace('"',''))
cmd = cmd.replace(found.group(0), shortName)
rc = None
if debugOutput == False:
progOutput = os.popen(cmd)
line = progOutput.readline()
while (line) != "":
if capture == True:
output.append(self.chomp(line))
if log == True:
print self.chomp(line)
line = progOutput.readline()
rc = progOutput.close()
else:
print "Would have executed: %s" % cmd
if rc == None:
rc = 0
if capture == True:
return rc, output
else:
return rc
“rc”的返回码是 2 而不是 none。有人知道python中的错误代码2是什么吗?