Python中assert的用法
Python中assert用来判断语句的真假,如果为假的话将触发AssertionError错误
如:
>>> a = 23
>>> a
23
>>> assert a == 23
>>> a -=1
>>> a
22
>>> assert a == 23
Traceback (most recent call last):
File "", line 1, in
assert a ==
23
AssertionError
>>>
时间: 2024-10-06 14:21:08