Skip to main content
 首页 » 编程设计

python之如何使用 eyed3 从 python 中的 .mp3 文件中获取详细信息(标题、艺术家)

2025年05月04日14rubylouvre

这是我的代码

import eyed3 
 
audiofile = eyed3.load("19 Calvin Harris - Summer.mp3") 
 
print(audiofile.tag.artist) 

这是一个错误

Traceback (most recent call last): 
  File "C:\Python34\testmp3.py", line 5, in <module> 
    print(audiofile.tag.artist) 
AttributeError: 'NoneType' object has no attribute 'artist' 

Visual Studio 中显示了属性。但是当我运行它时发生了错误

当我编写 print(audiofile) 时,它起作用了。我不知道为什么 附言。 Python 3.4。

请您参考如下方法:

试试这个代码,它对我有用

import eyed3 
 
def show_info(): 
    audio = eyed3.load("[PATH_TO_MP3]") 
    print audio.tag.artist 
    print audio.tag.album 
    print audio.tag.title 
 
show_info()