标签:
抛出异常:
try:
print("handel")
#raise #抛出异常
except Exception:
print(‘error!‘)
else:
print("no error just exec!!")
finally:
print("aways exec!")
print("一般用来关闭文件,sock等")
print("---------------")
断言:抛出布尔型错误。
try:
assert 1 == 0
except AssertionError:
print("not equal")
标签:
原文地址:http://www.cnblogs.com/fanxuanhui/p/5876448.html