下列语句中,不能捕获和处理异常的是
A: try:9/0
B: try:9/0except:print("除数不能为0")
C: try:9/0except Exception as e:print(e)
D: try:9/0except ZeroDivisionError as e:print(e)
A: try:9/0
B: try:9/0except:print("除数不能为0")
C: try:9/0except Exception as e:print(e)
D: try:9/0except ZeroDivisionError as e:print(e)
举一反三
- 处理异常时,要捕获异常发生的原因,可以使用以下语句( ): A: try: 代码块 except Exception B: try: 代码块 exception ExceptionName C: try: 代码块 except Exception as e D: try: 代码块 except Exception e
- 运行如下程序,输出结果是 。 try: x, y = 1, 0 z = x / y print(0, end=",") except: print("1", end=",") else: print("2", end=",") finally: print("3", end=",")
- Python的异常处理结构有: A: try…except结构 B: try…except…else结构 C: try…except…finally结构 D: assert语句
- 下列程序段执行后,输出结果是: number = 20 try: if number < 0: number = -number print(number,end=) except: print("有异常发生",end=) else: print("平安无事",end=) finally: print("我很好我可以的",end=)
- try:代码块except Exception as e :异常处理模块以上代码中的e代表