单选题 适中
#18337

执行下面Python代码,输入0和字符串“abc”后,输出的结果是?( ) try : a = int ( input ( ) ) b = int ( inpu…

执行下面Python代码,输入0和字符串“abc”后,输出的结果是?( )

try:
	a = int(input())
	b = int(input())
	x = a / b
	print(x, end="#")
except ZeroDivisionError:
	print(0, end="#")
except:
	print(1, end="#")
else:
	print(2, end="#")
finally:
	print(3, end="#")
未登录也能判分,登录后才会记录
答案与解析
正确答案:D
解析

第二个输入“abc”导致ValueError,触发通用except块打印1,最后finally块打印3,结果为1#3#。