我正在使用subprocess
模块调用不同的进程.然而,我有一个问题.
在以下代码中:
callProcess = subprocess.Popen(['ls', '-l'], shell=True)
和
callProcess = subprocess.Popen(['ls', '-l']) # without shell
两者都有效.读了这些文档之后,我知道shell=True
意味着通过shell执行代码.这意味着在缺席的情况下,这个过程直接开始.
So what should I prefer for my case - I need to run a process 和 get its output. What benefit do I have from calling it from within the shell or outside of it.