【发布时间】:2017-10-01 13:58:03
【问题描述】:
我有这个 python 代码:
import os
os.system('cd C:\yt')
os.system("ffmpeg.exe -i test.mp4 newfilename.mp3")
yt 文件夹包括 ffmeg.exe 和 test.mp4,但我在 cmd 上将代码分开编写,一切正常,但因此我收到以下错误消息:
'ffmpeg.exe' is not recognized as an internal or external command,
operable program or batch file.
如果我使用 C:\yt\ffmpeg.exe -i test.mp4 newfilename.mp3 不起作用,如果我只使用 os.system('cd C:\yt') 我不会收到错误消息。 我的代码有什么问题?
【问题讨论】:
-
os.system在子shell中执行命令,也就是说第二条命令不在C:\yt中执行 -
我重新修改:
subprocess.call("ffmpeg.exe -i test.mp4 newfilename.mp3",cwd=r"c:\yt")