Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/279.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 如何在不打开CMD窗口的情况下通过subprocess.call()运行CMD命令?_Python_Python 3.x_Windows_Subprocess - Fatal编程技术网

Python 如何在不打开CMD窗口的情况下通过subprocess.call()运行CMD命令?

Python 如何在不打开CMD窗口的情况下通过subprocess.call()运行CMD命令?,python,python-3.x,windows,subprocess,Python,Python 3.x,Windows,Subprocess,我能够使用Python通过CMD和subprocess.call('insert command here')运行命令,但它会打开CMD窗口,然后立即关闭。有没有办法完全不打开它?在调用子流程时,可以设置shell=True。调用: subprocess.call('insert command here', shell=True) 请参阅@OfirGottesman:这个问题是关于子流程的。检查call()而不是子流程。call()。它的参数与子流程相同。检查call(),无论如何,我会回答

我能够使用Python通过CMD和
subprocess.call('insert command here')
运行命令,但它会打开CMD窗口,然后立即关闭。有没有办法完全不打开它?

在调用
子流程时,可以设置
shell=True
。调用

subprocess.call('insert command here', shell=True)

请参阅@OfirGottesman:这个问题是关于
子流程的。检查
call()
而不是
子流程。call()
。它的参数与
子流程相同。检查
call()
,无论如何,我会回答
子流程。call
您知道为什么设置
shell=True
会抑制
cmd
窗口吗?在我看来,它会做相反的事情…