
创建异常:
class SomeCustomException(Exception): pss
捕捉异常
x=input('Enter the first number: ')
y=input('Enter the second number: ')
print x/y
##################
try:
x=input('Enter the first number: ')
y=input('Enter the second number: ')
print x/y
except ZeroDivisionError:
print "The second number can't be zero!"
网友评论