例子:

1 i = 1
2 while i < 10:
3     print(i)
4     i+=1
5 else:
6     print('finish')

输出1至9和finish

在while语句中同样支持for语句所支持的continue、break和else

相关文章: