跳过列表Python的元素

2024-04-19 04:34:33 发布

您现在位置:Python中文网/ 问答频道 /正文

我用Python打开了两个json文件。我想做这样的事情,如果一个条件不满足,我可以跳过当前元素,然后转到下一个元素。我的代码如下所示:

t_a = first json file
t = second json file
for token in t_a
    if token in t
     #do something
    if token not in t
     #skip the current token and move on to the next one

我的问题来自最后一步。我是python新手,不知道如何跳过当前元素


Tags: 文件the代码intokenjson元素for
1条回答
网友
1楼 · 发布于 2024-04-19 04:34:33

只需使用^{}

t_a = first json file
t = second json file
for token in t_a
    if token in t:
     #do something
    else:
     #skip the current token and move on to the next one
        continue
    #do something else here

相关问题 更多 >