当我写这篇文章时,我没有看到任何错误,但它打开了一个jpg文件而不是mp3文件

music_dir = 'C:\\Users\\Sannidhay\\Music'
songs = os.listdir(music_dir)
print(songs)
os.startfile(os.path.join(music_dir, songs[0]))
评论
non_at
non_at

You must try printing the file name for songs[0]. It is probably a jpg file and thus it is being opened by your program. Remove all non mp3 files from the Music directory and then try again.

点赞
评论
hquae
hquae

@Sannidhay尝试设置默认程序以在Music App或Windows Media Player中打开音乐文件,然后运行脚本。

点赞
评论