如何捕捉错误(200)

时间:2017-06-22 22:24:53

标签: python exception scikit-learn

我正在尝试从用户那里获得输入,直到他按下ctrl-c。然而,我无法抓住 error,我认为它与sklearn有关(我为其余的代码导入了它)

这是代码:

b = @(theta) y.*cos(theta)./((x-R.*cos(theta)).^2+y.^2+(z - ...
             R.*sin(theta)).^2).^(3/2);
integral(b,1,2)

ans =

   0.055781612354862

1 个答案:

答案 0 :(得分:1)

修改缩进,如下所示:

try:
    while(True):
        i+=1
        put = input("\tEnter name of feature number " + str(i) +":\t")
        features.append(put)
except KeyboardInterrupt:
    print("\n\tFeatures Added!")
    sleep(SLEEP)
    return None
except:
    exit("\nError has occurred, please come back later...")