断言:
类似与判断,后面的程序依赖前面的,可以加一个断言,断言成功继续执行。断言失败报错停止执行。
a = 'abc' assert type(a) is str print('yes') assert type(a) is int print('yes') #======输出结果======= yes Traceback (most recent call last): File "E:/pywww/day07/01.py", line 7, in <module> assert type(a) is int AssertionError