【发布时间】:2021-11-30 20:43:40
【问题描述】:
我有一个文件:“abc”,它是一个可执行文件。 我想通过 Phthon 或 windows CMD 执行。
如果我写代码:
subprocess.Popen('-a -b -c', creationflags=0x08, shell=True, executable="C:\\abc")
然后,执行了 abc,但是 params(-a -b -c) 被忽略了
那么...我该如何重新爱上它?
【问题讨论】:
-
你试过
subprocess.Popen("C://abc -a -b -c", shell=True)吗?见stackoverflow.com/questions/11284147/… -
这应该可以。首选方法是使用参数列表(并删除 shell=True)。你怎么能确定/证明这些论点被忽略了?例如这个工作:
p=subprocess.Popen("/c dir",executable=r"C:\Windows\System32\cmd.exe")
标签: python powershell cmd executable