问题
I have a mp3 with my artist tag in russian. All english meta data prints normally but the russian shows up as question marks. How can I force the module to use unicode or utf8 encoding?
python
from ID3 import *
import glob
import re
import os
for name in glob.glob('*.mp3'):
id3info = ID3(name)
print id3info
I am using this library: http://id3-py.sourceforge.net/
回答1:
You can't do Unicode in ID3v1, and that module only does ID3v1 (and it doesn't even do it correctly).
If you're explicitly trying to tag your files for some ID3v1-only application, then you really need to figure out how to trick that application into reading Russian characters. Most likely, that will be impossible. But if not, then you can trick your ID3v1 library into outputting strings that will trick your application, by manually pre-processing the strings.
However, if you're trying to tag your files for any modern application, just use Mutagen, Stagger, PyTagLib, or something else that's not a decade out of date. They'll all export valid Unicode in the ID3v2 tags, and do the best possible with the ID3v1 tags (which usually isn't great, but usually doesn't matter).
来源:https://stackoverflow.com/questions/10923086/python-id3-tag-unicode