python short circuit principle

A, and for, as long as the first calculation result is false, then the other is not calculated results, directly evaluates false

False and True == False

False and True or True or True == False

Example:

5<3  and  6>1

Calculated first result is False, the result has been determined and the expression is False, the back 6> 1, is not calculated.

Two, or for, as long as the first calculation result is true, then the other is not calculated results, directly determines true.

True or False == True

True or False and True or False  ==True

Example:

1!=2 or 9<0 and 7>8 ==True

 

Results after the calculation or not, is directly determined true.

Guess you like

Origin www.cnblogs.com/taotao1904/p/12068681.html