[英]Can I have subprocess.call write the output of the call to a string?
[英]How come I can't “cd” to a folder in subprocess.call?
我尝试使用subprocess.call(我想在该文件夹中运行命令)进入cd文件夹,回显是保持power-shell窗口打开。
subprocess.call([
"C:\\WINDOWS\\system32\\WindowsPowerShell\\v1.0\\powershell.exe",
"cd C:\dev\git-sites\Babyshop",
"echo 'test'"
])
当我尝试运行此程序时,在关闭窗口之前,我看到一个红色的错误消息闪烁。
如何保持Powershell打开或从中获取输出? 怎么不起作用?
您作为参数提供给call()
的列表不是要执行的命令的列表。 它是命令及其参数。 每个call()
只能执行一个命令调用。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.