控制结构
if 语句
# only if block if condition: if_true_block # if_else block if condition: if_true_block else: if_false_block # if_elif_else block if condition: if_true_block elif condition: elif_true_block elif condition: elif_true_block else: all_false_block # if 嵌套 block if outer_condition: if inner_condition: inner_condition_true_block else: inner_condition_false_block else: outer_if_false_block
while 结构
# while only while condition : while_clause # while-else clause: while condition: while_clause else: else_cluase
for 结构
# for结构 for iter_var in iterable: suite_to_repeat
原文地址:https://www.cnblogs.com/ryanpan/p/9264402.html
时间: 2024-11-05 12:20:56