Python subprocess.check_output(args) 失败,而通过 Windows 命令行执行的 args 工作正常

标签 python cmd subprocess

python的一些问题subprocess.check_output

output = subprocess.check_output(args)

我的args在哪里:

args = "C:\\DO\\bin\\Config.exe --ChCfg7 --LFE -b1152000 C:\\DO\\PCM\\1.wav C:\\DO\\PCM\\2.wav C:\\DO\\PCM\\3.wav C:\\DO\\PCM\\4.wav C:\\DO\\PCM\\5.wav C:\\DO\\PCM\6.wav --ModeBCast -oC:\\DO\\OUT\\outfile > C:\\DO\\OUT\\log.txt

这在从标准 Windows 命令行执行时有效,但在通过 Python subprocess.check_output 执行时无效。在 win cmd 情况下,也会生成输出文件和 log.txt,而 python 脚本会生成大小为 0 的输出文件,并且根本没有 log.txt。

最佳答案

output = subprocess.check_output(args,shell=True)

使用 shell=True 运行此命令

关于Python subprocess.check_output(args) 失败,而通过 Windows 命令行执行的 args 工作正常,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28450572/

相关文章:

python - Python 中 sudo 自动传递密码

python - 通过 Python 获取 MAPLE 的输出

python - 将 Python 2 程序移植到 Python 3,随机线生成器

python - IPython 7.0.1 中的多行编辑中断

windows - 如何为 FOR 循环中的每个命令获取 ERRORLEVEL?

cmd - 是否可以从命令行而不是 GUI 使用跟踪 32 功能?

Windows 批处理文件 - 忽略 GOTO 命令

用于 scp 文件的 Python 代码因名称解析问题而失败

python - 单个表上的 SQLAlchemy 多对多关系错误 : NoReferencedTableError

python - 使用 numpy 重复数组维度(不使用 np.repeat)