条件判断

条件判断 

if...elseif....else..

# condiction_1
# condiction_2
# condiction_3
if condiction_1:
    statement_block_1
elif condiction_2:
    statement_block_2
else:
    statement_block_3
condiction_1为True时,输出为 statement_block_1

条件判断语句结束
condiction_1为True时,输出为 statement_block_1

条件判断语句结束
condiction_1,condiction_1为false时,到else 代码块,输出为 statement_block_1

条件判断语句结束

条件语句的嵌套:
# condiction_1
# condiction_2
# condiction_3
if condiction_1:
    if condiction_2:
        statement_block_2
    else:
        statement_block_3
else:
    statement_block_1
condiction_1为True,进入下一个条件判断。

condiction_2为True,输出为statement_block_2,否者输出为statement_block_3
condiction_1为false,输出为
statement_block_1


 
 






 

猜你喜欢

转载自www.cnblogs.com/jiangxiaolong-1996/p/9231278.html
今日推荐