特性\\x00
表示值为零的单个字节在H
之前。所以,你的字符串看起来是这样的:
Zero - H - i - d - e ...
通常字符串有字母或数字在他们,而不是零。也许这个用法是特定于ID3v2的?
考虑的IDC3v2标准(http://id3.org/id3v2.4.0-structure),我们看到它是:
Frames that allow different types of text encoding contains a text
encoding description byte. Possible encodings:
$00 ISO-8859-1 [ISO-8859-1]. Terminated with $00.
$01 UTF-16 [UTF-16] encoded Unicode [UNICODE] with BOM. All
strings in the same frame SHALL have the same byteorder.
Terminated with $00 00.
$02 UTF-16BE [UTF-16] encoded Unicode [UNICODE] without BOM.
Terminated with $00 00.
$03 UTF-8 [UTF-8] encoded Unicode [UNICODE]. Terminated with $00.
所以,我们看到的是零字节表示ISO-8859-1编码,直到下一个零字节。
你的程序可能会解决这个问题,像这样:
title = fp.read(number_of_bytes)
if(title[0] == '\x00')
title = title[1:].decode('iso8859-1')
elif(title[0] == ... something else ...)
title = title[1:].decode('some-other-encoding')
...
大,感谢的人 –