python 示例
continue is a keyword in python just like another programming language and it is used to send the program’s section to loop by escaping the execution of next statement in the loop.
就像另一种编程语言一样, continue是python中的一个关键字,它用于通过转义循环中next语句的执行来将程序的部分发送到循环中。
In the given example, loop is running from 1 to 10 and we are using the continue statement if value of ‘i’ is 6. This when the value of i will be 6, program’s execution will continue without prating the 6.
在给定的示例中,循环从1到10运行,并且如果'i'的值为6,我们将使用continue语句。这在i的值为6时,程序的执行将继续进行而不会分页6。
Example 1:
范例1:
for i in range(1,11):
if(i==6):
continue
print(i)
Output
输出量
1
2
3
4
5
7
8
9
10
Example 2: In this example, we are printing character by character of the value/string “Hello world” and continuing the loop execution, if the character is space.
示例2:在此示例中,如果字符为空格,则按字符/值/字符串“ Hello world”打印字符,并继续执行循环。
for ch in "Hello world":
if ch == " ":
continue
print(ch)
Output
输出量
H
e
l
l
o
w
o
r
l
d
翻译自: https://www.includehelp.com/python/continue-statement-example.aspx
python 示例