python~youtubedl:error:没有这样的选项:audioform

2024-07-04 07:56:58 发布

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

这是我的代码:

call(['youtube-dl', '-i', '--extract-audio', '--audio-format mp3','-w','ytsearch:'+song ,'-o '+song2file(song)+'.%(ext)s'], shell=False)

在注意:这是此代码的实现:youtuble-dl -i --extract-audio --audio-format mp3 -w ytsearch:Wham Bam -o WhamBam.%(ext)s 其中song=whambam,当我运行这个cmd时,它工作得很好,但是python实现不起作用。在

运行它时返回给我:

youtube-dl: error: no such option: --audio-format


Tags: 代码falseformatsongyoutubeextractshellcall
1条回答
网友
1楼 · 发布于 2024-07-04 07:56:58

作为解决方案的一部分,最好像这样正确格式化字符串:

arg= ['-i', ' extract-audio', ' audio-format mp3','-w','ytsearch:'+song ,'-o 
'+song2file(song)+'.%(ext)s'];
yt-arg= " ".join(str(x) for x in arg);

那就叫它吧

^{pr2}$

这已经解决了您所描述的问题,但在-o选项上似乎仍然存在问题。 请记住正确格式化字符串,不要粗心大意。在

相关问题 更多 >

    热门问题