Python assert(断言)可以分别后面的判断是否正确,如果错误会报错
示例:
a = 1 assert type(a) is int print(‘No problem‘)
输出结果:
No problem
a = ‘1‘ assert type(a) is int print(‘No problem‘)
输出结果:
Traceback (most recent call last):
File "D:/test.py", line 3, in <module>
assert type(a) is int
AssertionError
原文:https://www.cnblogs.com/dbf-/p/10667344.html