Python子进程导致shell延迟

Python子进程导致shell延迟,python,shell,subprocess,latency,Python,Shell,Subprocess,Latency,下面的代码工作得非常好。但是,一旦调用了子流程并执行了外部python脚本,它就会开始快速弹出命令提示符,因为脚本的输出是纯文本。但是,我们已经尝试了所有方法来禁用该弹出窗口。我们尝试添加“shell=False”和“shell=None”。我们甚至尝试编辑外部脚本本身并修改其子进程调用,但它没有 if os.path.exists(oldpath): shutil.copy(root.wgetdir + "\\" + root.website.get() + "\\" + item, keyw

下面的代码工作得非常好。但是,一旦调用了子流程并执行了外部python脚本,它就会开始快速弹出命令提示符,因为脚本的输出是纯文本。但是,我们已经尝试了所有方法来禁用该弹出窗口。我们尝试添加“shell=False”和“shell=None”。我们甚至尝试编辑外部脚本本身并修改其子进程调用,但它没有

if os.path.exists(oldpath): shutil.copy(root.wgetdir + "\\" + root.website.get() + "\\" + item, keyworddir + "\\" + item)
            shellreturn = subprocess.check_output(["C:\Python34\python",root.wgetdir + "\html2text.py", keyworddir + "\\" + item])
            print(shellreturn)
            shelllist = shellreturn.decode().splitlines()

多亏了@J.F.Sebastian的相关帖子,我才知道如何消除shell弹出窗口。下面是我使用的代码

startupinfo = subprocess.STARTUPINFO()
startupinfo.dwFlags |= subprocess.STARTF_USESHOWWINDOW      
shellreturn = subprocess.check_output(["C:\Python34\python", root.wgetdir + "\html2text.py", keyworddir + "\\" + item], startupinfo=startupinfo) #this could be any subprocess.
使用
r“C:\Python\n\f”
而不是
“C:\Python\n\f”
。后者中有文字换行符(
“\n”
)。使用
os.path.join(keyworddir,item)
而不是
keyworddir+“\\”+item