使用某些代码,从命令提示符运行它时出现错误提示…
NameError: name 'Popen' is not defined
但我同时导入import os和import sys。
import os
import sys
这是代码的一部分
exepath = os.path.join(EXE File location is here) exepath = '"' + os.path.normpath(exepath) + '"' cmd = [exepath, '-el', str(el), '-n', str(z)] print 'The python program is running this command:' print cmd process = Popen(cmd, stderr=STDOUT, stdout=PIPE) outputstring = process.communicate()[0]
我缺少基本的东西吗?我不会怀疑。谢谢!
你应该做:
import subprocess subprocess.Popen(cmd, stderr=subprocess.STDOUT, stdout=subprocess.PIPE) # etc.