我使用eyed3添加歌词,我有这个代码
#-*-coding:utf-8-*-
import eyed3
mp3 = eyed3.load( r'F:\Music\=NEUTRAL=\桜華結界-Perfect Cherry Blossom-\04 - 早乙女の遊戯そして流儀(原曲:東方紅魔郷 U.N.オーエンは彼女なのか?).mp3'.decode('utf-8'))
mp3.tag.lyrics.set('哈哈测试ひびき')
mp3.tag.save()
当我使用IDE(pyCharm)运行它时。它给我一个错误
Traceback (most recent call last):
File "H:/Python/Xiami-music-lyrics/test.py", line 6, in <module>
mp3.tag.save()
File "C:\Python27\lib\site-packages\eyed3\id3\tag.py", line 773, in save
self._saveV2Tag(version, encoding, max_padding)
File "C:\Python27\lib\site-packages\eyed3\id3\tag.py", line 967, in _saveV2Tag
max_padding)
File "C:\Python27\lib\site-packages\eyed3\id3\tag.py", line 881, in _render
raw_frame = f.render()
File "C:\Python27\lib\site-packages\eyed3\id3\frames.py", line 1056, in render
self.text.encode(id3EncodingToString(self.encoding)))
UnicodeDecodeError: 'ascii' codec can't decode byte 0xe5 in position 0: ordinal not in range(128)
这是我的python控制台上的截图:
如何在我的IDE中修复我的代码以使其工作?抱歉英文不好。
答案 0 :(得分:2)
#-*-coding:utf-8-*-
import eyed3
mp3 = eyed3.load( r'F:\Music\=NEUTRAL=\桜華結界-Perfect Cherry Blossom-\04 - 早乙女の遊戯そして流儀(原曲:東方紅魔郷 U.N.オーエンは彼女なのか?).mp3'.decode('utf-8'))
mp3.tag.lyrics.set(u'哈哈测试ひびき')
mp3.tag.save(version=eyed3.id3.ID3_DEFAULT_VERSION,encoding='utf-8')
解决了问题: - )