Python中assert用来判断语句的真假,如果为假的话将触发AssertionError错误
python help document的解释:
Assert statements are a convenient way to insert debugging assertions into a program:
例:
>>> a = 3
>>> assert a ==3
>>> a = 2
>>> assert a ==3
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AssertionError
例2: