捕捉异常(1)

来源:互联网 发布:伊丽莎白镇 知乎 编辑:程序博客网 时间:2024/05/17 06:56
try:    x=input('Enter the first number:')    y=input('Enter the second number:')    print x/yexcept ZeroDivisionError:    print "The second number can't be zero!"

Enter the first number:10
Enter the second number:0
The second number can't be zero!
0 0
原创粉丝点击