本文实例讲述了python在windows下创建隐藏窗口子进程的方法。分享给大家供大家参考。具体实现方法如下:
import subprocess
is_win32 = ‘win32’ in str(sys.platform).lower()
def subprocess_call(*args, **kwargs):
#also works for popen.
#it creates a new *hidden* window,
#so it will work in frozen apps (.exe).
if is_win32:
startupinfo = subprocess.startupinfo()
startupinfo.dwflags = subprocess.create_new_console | subprocess.startf_useshowwindow
startupinfo.wshowwindow = subprocess.sw_hide
kwargs[‘startupinfo’] = startupinfo
retcode = subprocess.call(*args, **kwargs)
return retcode
希望本文所述对大家的python程序设计有所帮助。