参考以下代码,一看就懂:

    1. # need python3
    2. from mutagen.easyid3 import EasyID3
    3. import os
    4. basedir = os.path.abspath(os.path.dirname(__file__))
    5. # print(basedir)
    6. def process(file_dir):
    7. L=[]
    8. for root, dirs, files in os.walk(file_dir):
    9. for file in files:
    10. # print(file)
    11. if file.find(".mp3") > 0:
    12. print(file)
    13. arr = file.rsplit('.',1)
    14. audio = EasyID3(basedir+"/"+file)
    15. audio['artist'] = u"Me"
    16. audio.save()
    17. process(basedir)
    18. # 其他用法
    19. # audio = EasyID3("example.mp3")
    20. # audio['title'] = u"Example Title"
    21. # audio['artist'] = u"Me"
    22. # audio['album'] = u"My album"
    23. # audio['composer'] = u"" # clear
    24. # audio.save()
    25. # import eyed3
    26. # audiofile = eyed3.load("song.mp3")
    27. # audiofile.tag.artist = u"Nobunny"
    28. # audiofile.tag.album = u"Love Visions"
    29. # audiofile.tag.title = u"I Am a Girlfriend"
    30. # audiofile.tag.track_num = 4
    31. # audiofile.tag.save()