2024-06-26 17:39:50 发布
网友
我想做一个Python代码,它将像cmd那样打开一个程序,然后从文件菜单导出一个.txt文件。cmd的代码如下:
c:\ESG\Statsvis.exe \\192.168.100.222\c\ESG\S1-424\2012\06\29\S1-42420120629.dsf /output=C:\Users\jessica.macleod\Desktop\outfile.txt /param=RMS Amplitude
在命令行中,上面的行正是我想要的。Python的等价物是什么?
如果希望具有精确的shell/cmd行为,那么在一个suprocess.Popen()调用中将shell参数设置为True。但是,从文件来看:
suprocess.Popen()
shell
True
WarningInvoking the system shell with shell=True can be a security hazard if combined with untrusted input. See the warning under Frequently Used Arguments for details.
Warning
Invoking the system shell with shell=True can be a security hazard if combined with untrusted input. See the warning under Frequently Used Arguments for details.
请参见subprocess.Popen,如下所示:
subprocess.Popen(["/bin/ls", "-l"]
或者,根据您希望得到的结果(stdout,返回代码),使用本模块中的subprocess.call、subprocess.call_check或其他片段。
subprocess.call
subprocess.call_check
另一种方法是os.system()。
import os os.system("c:\\ESG\\Statsvis.exe \\192.16...0629.dsf /output=C:\\...\\outfile.txt ...")
如果希望具有精确的shell/cmd行为,那么在一个
suprocess.Popen()
调用中将shell
参数设置为True
。但是,从文件来看:请参见subprocess.Popen,如下所示:
或者,根据您希望得到的结果(stdout,返回代码),使用本模块中的
subprocess.call
、subprocess.call_check
或其他片段。另一种方法是os.system()。
相关问题 更多 >
编程相关推荐