引发异常波蟒

时间:2016-09-16 13:20:23

标签: python exception wave

我使用波形模块 例如。

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

获得输出

$scope.country= ""

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

1 个答案:

答案 0 :(得分:1)

如果您希望在提出预期后继续,您必须抓住它:

 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