Python continue 语句跳出本次循环,而break跳出整个循环。
for循环中使用continue
if __name__ == '__main__':
for i in range(10):
if i == 5:
continue
print(i)
while循环中使用continue
if __name__ == '__main__':
i = 0
while i < 10:
i += 1
if i == 5:
continue
print(i)
Python continue 语句跳出本次循环,而break跳出整个循环。
for循环中使用continue
if __name__ == '__main__':
for i in range(10):
if i == 5:
continue
print(i)
while循环中使用continue
if __name__ == '__main__':
i = 0
while i < 10:
i += 1
if i == 5:
continue
print(i)