In Windows , to use echo in subprocess, you would need to use shell=True . This is because echo is not a separate executable, but rather a built-in command for the windows command line. Example -
在windows 在子进程中使用echo,需要设置 shell =True,因为 echo 不是单独的命令,而是window CMD 内置的命令process1 = subprocess.Popen(command1,stdout=subprocess.PIPE,shell=True)1
Also, please do note, you should only use shell=True when absolutely necessary (as in this case , to use echo in windows in subprocess).
3 个回复
天涯浪子 - SSRS开发、数据仓库设计 2018-04-18 回答
赞同来自:
In Windows , to use echo in subprocess, you would need to use shell=True . This is because echo is not a separate executable, but rather a built-in command for the windows command line. Example -
在windows 在子进程中使用echo,需要设置 shell =True,因为 echo 不是单独的命令,而是window CMD 内置的命令process1 = subprocess.Popen(command1,stdout=subprocess.PIPE,shell=True)1
Also, please do note, you should only use shell=True when absolutely necessary (as in this case , to use echo in windows in subprocess).
并且,需要注意,只有在绝对需要的情况下才使用shell=True
找到 subprocess.py脚本,将对应行加上shell=true 参数。
该问题解决。
ID王大伟 - 人生苦短,我选Python。 2018-04-27 回答
赞同来自:
18818785070 2018-12-27 回答
赞同来自: