python基础教程笔记(chapt.8) 异常
2018-08-03 本文已影响6人
JuneZhu_870a

创建异常:
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!"