Python循环结构中else用法(入门必读)

1年前 (2024-04-26)
Python 中,无论是 while 循环还是 for 循环,其后都可以紧跟着一个 else 代码块,它的作用是当循环条件为 False 跳出循环时,程序会执行 else 代码块中的代码。

以 while 循环为例,下面程序演示了如何为 while 循环添加一个 else 代码块:

add = "http://c.biancheng网站站点" rel="nofollow" /> http://c.biancheng网站站点" rel="nofollow" />

add = "http://c.biancheng网站站点" rel="nofollow" /> http://c.biancheng网站站点" rel="nofollow" />

add = "http://c.biancheng网站站点" rel="nofollow" /> http://c.biancheng网站站点" rel="nofollow" />