try:
if '1' != 1:
raise "someError"
else:
print("someError has not occured")
except "someError":
print ("someError has occured")
a)someError has occured
b)someError has not occured
c)无效代码
d)以上都没有
try:
if '1' != 1:
raise "someError"
else:
print("someError has not occured")
except "someError":
print ("someError has occured")
a)someError has occured
b)someError has not occured
c)无效代码
d)以上都没有
c)代码无效。新的异常类必须从BaseException继承。
c) 无效代码
存在问题1: '1'不是int类型
存在问题2: except 语句后方只能添加已知的基类为BaseException的异常,不能抛出类似'someError' 的未知异常. 语法错误