问题描述
例如,我正在使用 ffplay
并想运行此命令 -bufsize [:stream_specifier]整数(输出,音频,视频)
For example I am using ffplay
and want to run this command -bufsize[:stream_specifier] integer (output,audio,video)
此刻我有这个东西:
subprocess.call(["ffplay", "-vn", "-nodisp","-bufsize 4096", "%s" % url])
但这说明它是无效的。
推荐答案
正如JBernardo在注释,将-bufsize 4096
参数分成两个-bufsize, 4096
。当 subprocess.call
与 shell = False
(默认值)一起使用时,每个参数都需要分开。您还可以指定 shell = True
并将整个命令作为单个字符串给出,但是由于存在潜在的安全漏洞,因此不建议这样做。
As JBernardo mentioned in a comment, separate the "-bufsize 4096"
argument into two, "-bufsize", "4096"
. Each argument needs to be separated when subprocess.call
is used with shell=False
(the default). You can also specify shell=True
and give the whole command as a single string, but this is not recommended due to potential security vulnerabilities.
如果您有%s%url
,则无需使用字符串格式。如果 url
是字符串,则直接传递它,否则调用 str(url)
获得字符串表示形式。
You should not need to use string formatting where you have "%s" % url
. If url
is a string, pass it directly, otherwise call str(url)
to get a string representation.
这篇关于Python子流程参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!