a =1
b =2assert a == b
# 输出,可以帮助我们锁定出错的位置,有利于debug
Traceback (most recent call last):
File "D:/source code/SRFBN_CVPR19/reference/assert.py", line 8,in<module>assert a == b
AssertionError
3.2 assert后跟参数
A =1
B =2assert A == B,'A is not equal to B!!'# 输出
Traceback (most recent call last):
File "D:/source code/SRFBN_CVPR19/reference/assert.py", line 8,in<module>assert A == B,'A is not equal to B!!'
AssertionError: A isnot equal to B!!