我正在从 Excel 文档中提取文本并将它们作为 id3 标记添加到一些 mp3 文件中。我的 Excel 文档中的大多数字符都是俄语 (Unicode),但有些是英语。当我运行脚本时,所有英文标签都被正确地写入元数据,但所有俄语字符都显示为问号。如果我在控制台中打印俄语字符,它们会完美显示。为什么他们被写成问号?
Python
from mutagen.easyid3 import EasyID3
import xlrd
import glob
import re
import os
for name in glob.glob('*.mp3'):
audio = EasyID3(name)
wb = xlrd.open_workbook('xl.xls')
sh = wb.sheet_by_name(u'Russian')
col_b = 1
col_c = 2
col_e = 4
col_g = 6
col_i = 8
col_k = 10
for i in range(sh.nrows):
row = sh.row_values(i)
for j in range(len(row)):
if row[j] == name:
audio["title"] = sh.cell(i,col_e).value
audio["author"] = sh.cell(i,col_i).value
audio["copyright"] = sh.cell(i,col_g).value
audio["album"] = sh.cell(i,col_k).value
audio["discsubtitle"] = sh.cell(i,col_c).value
audio.save()
print "All MP3 MetaData Parsed!"