开发者

python : how to use wave module?

开发者 https://www.devze.com 2023-02-19 17:54 出处:网络
when I try the following program : import wave w = wave.open(\'f.wav\', \'r\') for i in range():开发者_开发百科

when I try the following program :

import wave  
w = wave.open('f.wav', 'r')  
for i in range():  开发者_开发百科
    frame = w.readframes(i)  

the following error comes :

Traceback (most recent call last):  
  File "F:/Python31/fg.py", line 2, in <module>  
    w = wave.open('f.wav', 'r')  
  File "F:\Python31\lib\wave.py", line 498, in open  
    return Wave_read(f)  
  File "F:\Python31\lib\wave.py", line 159, in __init__  
    f = builtins.open(f, 'rb')  
IOError: [Errno 2] No such file or directory: 'f.wav'  

can u tell me wat could b the reason ???


The file is not in the path you put that Python interpreter can find. Check that f.wav is in the same path of your script (or chance the path in open). Is not a wave issue at all.


You are running the python script from a directory where no file f.wav exists. It can't find the file to read. Either copy f.wav to that directory or run you script from the directory f.wav is located in.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号