欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

python中的continue与break

程序员文章站 2024-03-15 12:58:11
...
for i in range(len(transactions)):
            a=transactions[i].split(',')
            if int(a[2])>1000:
                res.append(transactions[i])
                continue
            for j in range(len(transactions)):
                b=transactions[i].split(',')
                c=transactions[j].split(',')
                if b[0]==c[0] and b[3]!=c[3] and abs(int(b[1])-int(c[1]))<=60:
                    if transactions[i] not in res:
                        res.append(transactions[i])
                        break

continue表示跳过此次循环,且

 for j in range(len(transactions)):
                b=transactions[i].split(',')
                c=transactions[j].split(',')
                if b[0]==c[0] and b[3]!=c[3] and abs(int(b[1])-int(c[1]))<=60:
                    if transactions[i] not in res:
                        res.append(transactions[i])
                        break

这段语句不会被执行


break表示结束循环

for j in range(len(transactions)):
...

这个循环终止了结束了