如何在 Python 循环中使用 continue 语句?
pythonserver side programmingprogramming更新于 2025/8/10 16:44:17
循环控制语句 continue 放弃循环块当前迭代中的待处理语句并开始下一次迭代。continue 语句出现在循环内的条件块中
示例
x=0
while x<10:
x=x+1
if x==5: continue
print ('x=',x)
输出显示,当 x 为 5 时,不执行 print 语句,并从 x=6 开始进行下一次迭代打印
输出
x= 1 x= 2 x= 3 x= 4 x= 6 x= 7 x= 8 x= 9 x= 10
相关文章
有用资源
python 参考教程 - 该教程包含有关 python 的更多信息:https://www.cainiaomax.com/python/

