def test(a,b):
try:
c = a / b
except ZeroDivisionError:
print('Error!')
print('hello world')
test(2,0)
#输出
Error!
hello world
程序在执行完try……except……后,不会直接跳出函数,而是往下继续执行。
def test(a,b):
try:
c = a / b
except ZeroDivisionError:
print('Error!')
print('hello world')
test(2,0)
#输出
Error!
hello world
程序在执行完try……except……后,不会直接跳出函数,而是往下继续执行。