0
當我關閉文件對象時,得到的返回碼是2而不是「無」。Python中的返回代碼Fileobject.Close()
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,而不是在無。 有沒有人有一個想法是什麼在Python中的錯誤代碼?
感謝您的回答。但文件存在那裏。這隻發生在特定的機器上。並非所有的機器。 Close()方法的返回碼是2而不是None。 –
我真的不能爭辯,因爲我不知道你的情況是什麼''cmd''。但我傾向於相信文檔。如果它說''close''返回''cmd''的出口代碼,那麼''cmd''由於某種原因在這臺特定的機器上返回2。 – fjarri