python获取mp3文件信息

清华大佬耗费三个月吐血整理的几百G的资源,免费分享!....>>>

将代码生成.py文件放在目录下运行,可以获取该目录的所有mp3文件的信息,需要使用ID3库

import os, sys
from ID3 import *
  
files = os.listdir(os.getcwd())
  
for f in files:
    x = os.path.splitext(f)
    if x[1] == '.mp3':
        n = x[0].split(' - ')
        author = n[0]
        title = n[1]
        id3info = ID3(f)
        id3info['ARTIST'] = author
        id3info['TITLE'] = title
        print f+' id3 tagged.'
print 'Done!'