如何使用eyed3从python中的.mp3文件获取细节(标题,艺术家) [英] How to get detail (Title,Artist) from .mp3 files in python using eyed3

查看:503
本文介绍了如何使用eyed3从python中的.mp3文件获取细节(标题,艺术家)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我的代码

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中显示了属性.但是当我运行它时.发生了错误

There's attributes shown in Visual Studio. but when i run it.an error occurred

当我写print(audiofile)时,它起作用.我不知道为什么 ps. Python 3.4.

when i write print(audiofile) it works. i don't know why ps. Python 3.4.

推荐答案

标题和艺术家可通过Tag()返回值的访问器函数获得.下面的示例演示如何使用getArtist()getTitle()方法获取它们.

Title and Artists are available through accessor functions of the Tag() return value. The example below shows how to get them using getArtist() and getTitle() methods.

 import eyed3
 tag = eyed3.Tag()
 tag.link("/some/file.mp3")
 print tag.getArtist()
 print tag.getTitle()

这篇关于如何使用eyed3从python中的.mp3文件获取细节(标题,艺术家)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆