Python subprocess arguments(Python 子进程参数)
问题描述
例如我正在使用 ffplay
并想运行这个命令 -bufsize[:stream_specifier] integer (output,audio,video)
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 子进程参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:Python 子进程参数


基础教程推荐
- 在同一图形上绘制Bokeh的烛台和音量条 2022-01-01
- 包装空间模型 2022-01-01
- 在Python中从Azure BLOB存储中读取文件 2022-01-01
- PANDA VALUE_COUNTS包含GROUP BY之前的所有值 2022-01-01
- 修改列表中的数据帧不起作用 2022-01-01
- Plotly:如何设置绘图图形的样式,使其不显示缺失日期的间隙? 2022-01-01
- PermissionError: pip 从 8.1.1 升级到 8.1.2 2022-01-01
- 求两个直方图的卷积 2022-01-01
- 无法导入 Pytorch [WinError 126] 找不到指定的模块 2022-01-01
- 使用大型矩阵时禁止 Pycharm 输出中的自动换行符 2022-01-01