跳过列表的元素-Python
我有两个用Python打开的json文件。我想做一些事情,如果一个条件不满足,我可以跳过当前元素,继续下一个。我的代码如下所示:跳过列表的元素-Python,python,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 最后一步是我的问
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新手,不知道如何跳过当前元素,只需使用:
只需使用:
只需使用:
只需使用:
语句?您还需要将这两个文件加载到内存中。由于您是新的代码,我建议您应该在这里发布整个代码。另外,请看一下continue语句,如@thefourtheye建议的那样。因此,类似于token=test\u list.skip()continue这样的语句,只需去掉第二个
if
语句即可。语句?您还需要将这两个文件加载到内存中。由于您是新的代码,我建议您应该在这里发布整个代码。另外,请看一下continue语句,如@thefourtheye建议的那样。因此,类似于token=test\u list.skip()continue这样的语句,只需去掉第二个if
语句即可。语句?您还需要将这两个文件加载到内存中。由于您是新的代码,我建议您应该在这里发布整个代码。另外,请看一下continue语句,如@thefourtheye建议的那样。因此,类似于token=test\u list.skip()continue这样的语句,只需去掉第二个if
语句即可。语句?您还需要将这两个文件加载到内存中。由于您是新的代码,我建议您应该在这里发布整个代码。另外,请看一下continue语句,如@thefourtheye建议的那样。因此,类似于token=test\u list.skip()continue这样的语句,只需去掉第二个if
语句即可。
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