python中try语句中的语句未被except捕获

python中try语句中的语句未被except捕获
a = 'a'
b = 1
try :
    af = float ( a )
    bf = float ( b )
    c = af / bf
except TypeError :
    print ( 'They are not float' )
except ZeroDivisionError :
    print ( 'Can not be divided by ZERO' )
else :
    cf = c ** (1 / 3)
    print ( cf )

img

尝试分开检测但还是报错
except可以检测异常

因为发生的异常类型是ValueError,而你的except语句没有捕获这种类型的异常

a = 'a'
b = 1
try :
    af = float ( a )
    bf = float ( b )
    c = af / bf
except TypeError :
    print ( 'They are not float' )
except ZeroDivisionError :
    print ( 'Can not be divided by ZERO' )
except ValueError:
    print ('ValueError')
else :
    cf = c ** (1 / 3)
    print ( cf )