assert()方法,断言成功,则程序继续执行,断言失败,则程序报错
''' 断言 ''' a = 5 assert (a>1) print("断言成功,程序继续进行") assert (a>7) print("断言失败,程序报错")
'''
断言成功,程序继续进行
Traceback (most recent call last):
File "D:/pythonProjects/djangoProjects/DistributeSpider1807/lianxi/lianxi2.py", line 221, in <module>
assert (a>7)
AssertionError
'''