我正在使用Python编写一个程序来编辑mp3上的标签,现在我正在使用诱变剂模块,为了将图像作为封面嵌入到使用id3v4标准的mp3文件中,我必须添加APIC框架using this。在
但是我不明白我必须在参数encoding
、mime
和{
我从这里看了一个例子,想到了这个:
frame= APIC(3,"image/jpg",3,"Cover",open("albumcover.jpg"))
但我不知道前三个是什么意思?为什么当我把"utf-8"
放进去时它不起作用?并且open()
函数不起作用,它返回如下错误:
当我把"b"
frame= APIC(3,"image/jpg",3,"Cover",open("albumcover.jpg","b"))
返回它
Traceback (most recent call last):
File "<pyshell#106>", line 1, in <module>
frame= APIC("utf-8","image/jpg",3,"Cover",open("albumcover.jpg","b"))
ValueError: Must have exactly one of create/read/write/append mode and at most one plus
那我该放什么呢?在
我也试过了,但没用。在
参数
3
表示它是相册的封面read the documentation。在您需要以-
read
(rb)或write
(wb)或append
(ab)模式打开文件(b-表示它是一个二进制文件,我们从中读取字节而不是字符串)。在对于您的情况,我认为
read
模式就足够了,所以请尝试-rb
表示我们需要以读取模式打开该文件,并且它是一个二进制文件,对其调用.read()
函数会导致它从文件中读取字节并返回。在相关问题 更多 >
编程相关推荐