你好,我正在制作一个youtube视频下载器,和一个视频转换器来练习python语言。使用视频转换器,我尝试将mp4文件转换为mp3文件。我希望用户在不打开文本编辑器的情况下输入指定的路径。我的问题是。如果可能的话,我很难弄清楚如何使用用户的输入来转换文件。有人能帮我一下吗?
以下是我到目前为止拥有的代码:
import moviepy.editor as mp
#ask the user for the location of the file
loca = (input("Please input the location of the video file you wish to convert: "))
# Insert Local Video File Path
clip = mp.VideoFileClip(r'loca')
# Insert Local Audio File Path
clip.audio.write_audiofile(r'loca')发布于 2021-09-16 09:43:55
只需键入文件的扩展名即可
如果你无法想象,这就是它的样子。
import moviepy.editor as mp
#ask the user for the location of the file
loca = (input("Please input the location of the video file you wish to convert: "))
filename = input("File name. : ")
# Insert Local Video File Path
clip = mp.VideoFileClip(loca)
# Insert Local Audio File Path
clip.audio.write_audiofile(filename)https://stackoverflow.com/questions/65030619
复制相似问题