捕获多个异常不起作用

时间:2017-12-09 21:02:58

标签: python

我尝试使用try除了捕获多个异常。然而,我仍然无法捕捉到两个期望和错误打印出来如下。任何帮助表示赞赏

public Boolean isValidLength(String s) {
    return s.length == 6;
}

//this checks all characters of the string though, 
//your javadoc said something about checking the last 5 characters..
public Boolean hasValidDigits(String s) {
    for(int i=1; i<s.length(); i++)
        if (!Character.isDigit(s.charAt(i)))  {
            return false;
        }
    }
    return true;
}

public Boolean isValidAccountNum(String s) {
  return isValidLength(s) && isValidStart(s) && hasValidDigits(s);
}
def try_expection(self:
    try:
        el = self.element.test_function()
    except (AttributeError, TypeError):
        el = self.driver.test_function()

Error:
def try_expection(self):
    try:
     

E AttributeError:&#39; NoneType&#39;对象没有属性&#39; test_function&#39;

0 个答案:

没有答案