简体   繁体   English

Python诱变无法正确保存

[英]Python mutagen not saving correctly

I am pulling text from an Excel document and adding them as id3 tags to some mp3 files. 我正在从Excel文档中提取文本,并将其作为id3标签添加到一些mp3文件中。 Most of the characters in my Excel document are Russian (Unicode) but some are in English. 我的Excel文档中的大多数字符都是俄语(Unicode),但有些是英语。 When I run the script, all the English tags get written as meta data correctly, but all the Russian characters show up as question marks. 当我运行脚本时,所有英文标签都正确地写为元数据,但是所有俄语字符都显示为问号。 If I print the Russian characters in my console, they show up perfectly. 如果我在控制台中打印俄语字符,它们会完美显示。 Why are they getting written as question marks? 为什么将它们写为问号?

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!"

you should use 'decode' or/and 'encode' methods. 您应该使用“解码”或/和“编码”方法。

The great answer about: https://stackoverflow.com/a/370199/1321404 很棒的答案: https : //stackoverflow.com/a/370199/1321404

anoter way: https://stackoverflow.com/a/4631545/1321404 另一种方式: https ://stackoverflow.com/a/4631545/1321404

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM