-6
import shlex
import os
os.environ['SERVER_SOFTWARE'] = 'Dev'
import subprocess, socket, time, struct
def execute_command(cmd):
f = open(log.name, "w")
try:
subprocess.Popen(cmd, 0, f, f)
except WindowsError:
cmd[0] = cmd[0] + ".com"
subprocess.Popen(cmd, 0, f, f) #work-around
rc = process.wait()
if rc != 0:
print("Error: failed to execute command:", cmd)
print(error)
return result
def main():
execute_command(["tree", "C:\\"], "treelog.txt")
return
'def_main():'似乎是一個錯字。你可能是指'def main():'如果你要編程,你需要提高對細節的關注。 –
另外,請正確格式化您的代碼。這是不可讀的。 –
您可以顯示只傳遞一個參數到'execute_command'的版本嗎?通過兩個參數是一個錯誤是顯而易見的。 – mkrieger1