问题描述
我有一个带有俄语歌手标签的mp3.所有英语元数据都可以正常打印,但是俄语显示为问号.如何强制模块使用unicode或utf8编码?
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
我正在使用此库: http://id3-py.sourceforge.net/
推荐答案
您无法在ID3v1中执行Unicode,并且该模块仅执行ID3v1(甚至无法正确执行).
You can't do Unicode in ID3v1, and that module only does ID3v1 (and it doesn't even do it correctly).
如果您要明确地为仅ID3v1的应用程序标记文件,那么您确实需要弄清楚如何诱使该应用程序读取俄语字符.最有可能的是,那将是不可能的.但是,如果没有,那么您可以通过手动预处理字符串来欺骗ID3v1库,以输出将欺骗您的应用程序的字符串.
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.
但是,如果您要为任何现代应用程序标记文件,只需使用Mutagen,Stagger,PyTagLib或其他尚未过期的文件即可.他们都将在ID3v2标签中导出有效的Unicode,并使用ID3v1标签(可能并不好,但通常没关系)尽最大可能.
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).
这篇关于python id3标签unicode的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!