使用Python中的子进程运行mplayer

2024-05-16 05:29:05 发布

您现在位置:Python中文网/ 问答频道 /正文

我想用python运行mplayer,下面是我的代码

from subprocess import call 
call (mplayer /root/Desktop/file.mp4)

但它不起作用,我犯了这个错误

^{pr2}$

我做错什么了?


Tags: 代码fromimport错误rootcallfilemp4
1条回答
网友
1楼 · 发布于 2024-05-16 05:29:05

您需要使用shell=False传递一个参数列表(默认值):

call(["mplayer", "/root/Desktop/file.mp4"])

或者对于单个字符串,您需要shell=True

^{pr2}$

但是没有必要使用后者,第一种会很好地工作。在

相关问题 更多 >