in python assert usage

assert: Assertion

 

format:

assert expression [parameters]

When the expression is true, the program to continue;

When the expression is false, throw AssertionError error and output parameters

 

For example:

DEF foo (S): 
    n- = int (S)
     Assert n-= 0,! ' n-IS ZERO! ' 
    return 10 / n- 

foo ( ' 0 ' ) 

# code execution result 
# AssertionError with: n-IS ZERO!

 

Guess you like

Origin www.cnblogs.com/shuaishuaidefeizhu/p/11324654.html