我找到了这个主题,我发现这是一个解决方案:
模块子进程没有属性“STARTF_USESHOWWINDOW”
但是当我运行代码时,实际情况有所不同。:/
运行我的代码:
# Get the environment variables from OO-Python using subprocess oo_py_exec = os.path.join(oo_dir, r'program\python.exe') python_oo_script = ' ;'.join([ "-cimport os", "print(os.environ['URE_BOOTSTRAP'])", "print(os.environ['UNO_PATH'])", "print(os.environ['PATH'])", ]) subprocess.STARTF_USESHOWWINDOW info = subprocess.STARTUPINFO() info.dwFlags = subprocess.STARTF_USESHOWWINDOW info.wShowWindow = subprocess.SW_HIDE process = subprocess.Popen([oo_py_exec, python_oo_script], stdout=subprocess.PIPE, startupinfo=info) result = process.communicate()
显示控制台。
从链接运行代码:
kwargs = {} if subprocess.mswindows: su = subprocess.STARTUPINFO() su.dwFlags |= subprocess.STARTF_USESHOWWINDOW su.wShowWindow = subprocess.SW_HIDE kwargs['startupinfo'] = su subprocess.Popen("cmd.exe", **kwargs)
控制台也显示了!
赢 xp, py 2.6