continue表示跳过后面的程序,重新循环,而pass表示站位,什么也不做,后面的代码(else之前)还是会执行,
a = 'python' i = 2 for element in a: if element == 'y': pass i = 3 else: print(element+str(i)) 结果是 p2 t3 h3 o3 n3
a = 'python' i = 2 for element in a: if element == 'y': continue i = 3 else: print(element+str(i)) 结果是 p2 t2 h2 o2 n2