引发异常波 python

raise exception wave python

我用的是wave模块 例如 .

     import wave
     origAudio = wave.open("son.wav",'r')

获取输出

       raise Error, 'file does not start with RIFF id'
       wave.Error: file does not start with RIFF id

我知道文件不好,但我想提出这个异常或这个错误

如果您希望在引发异常后继续,您必须捕获它:

 import wave
 try:
   origAudio = wave.open("son.wav",'r')
 except wave.Error as e:
   # if you get here it means an error happende, maybe you should warn the user
   # but doing pass will silently ignore it
   pass