Usage and precautions of assert (assertion) in python

grammatical format

assert expression , AssertionError

# 等价于

if not expression:
	raise AssertionError(arguments)
	

assrt is equivalent to an if conditional judgment statement, but it can simplify the code better.

effect

Simplify the code and reduce the use of if statements. It is generally used in the development process of the code and will not appear in the product.

Guess you like

Origin blog.csdn.net/w2190623446/article/details/129044732