无法使findstr与在Windows上运行的子进程一起使用

我想从我的python环境中运行findstr,并且在使用子进程run调用时无法使它正常工作(我可以使用dos提示符从命令行运行findstr命令):

commandlist = ['findstr','/s','"texttofind"','*.py']
cwd = 'e:\\python'
shell = True
encoding = 'utf-8'
output = subprocess.run(commandlist,stdout=subprocess.PIPE,stderr=subprocess.PIPE,encoding=encoding,shell=shell,cwd=cwd)

的返回码为1:

CompletedProcess(args=['findstr','"runrcode"','*.py'],returncode=1,stdout='',stderr='')

如果我改用commandlist = ['path'],那么一切正常,导致返回码0和stdout以及预期的路径文本列表(当然,shell必须为True才能起作用)。

有关如何使其正常工作的任何想法?不知道我在想什么。非常感谢。

gsephiroth 回答:无法使findstr与在Windows上运行的子进程一起使用

暂时没有好的解决方案,如果你有好的解决方案,请发邮件至:iooj@foxmail.com
本文链接:https://www.f2er.com/3150204.html

大家都在问