WAVファイルからインデックス位置を返そうとしています。
干し草の山で針の内容が見つかった場合は、干し草の山で針のインデックス位置を返す必要があります。
haystack = open("haystack.wav",'r').read()
needle = open("needle.wav",'r').read()
print(haystack.index(needle[:46]));
エラーが発生します:
Traceback (most recent call last):
File "test.py", line 1, in <module>
haystack = open("haystack.wav",'r').read()
File "C:\Python33\lib\encodings\cp1252.py", line 23, in decode
return codecs.charmap_decode(input,self.errors,decoding_table)[0]
UnicodeDecodeError: 'charmap' codec can't decode byte 0x8f in position 5: character maps to <undefined>
PHPでこれを行うと機能します。
$needle = file_get_contents("needle.wav", false, null, 46);
$haystack = file_get_contents("haystack.wav");
echo strpos($haystack,$needle);