wor*_*ad3 3 python windows subprocess command-line-arguments
我目前遇到一个python脚本的主要问题.该脚本通过处理程序运行任意命令,以将错误的错误报告转换为正确的错误报告.
我遇到的问题是让脚本在Windows上正常工作,其命令在其路径中包含&符号.我试图引用命令,用^来逃避&符号,但都不起作用.我现在已经没想法了.有什么建议?
从目前的答复中澄清:
[Error 123] The filename, directory name, or volume label syntax is incorrect错误shell=false)p = subprocess.Popen(prog,stderr = subprocess.PIPE,bufsize = -1)
当列表'prog'的第一个元素包含任何&符号时.引用第一个字符串不起作用.
确保您使用的是列表而没有shell扩展:
subprocess.Popen(['command', 'argument1', 'argument2'], shell=False)
Run Code Online (Sandbox Code Playgroud)