2014-03-30 102 views
0

我有兩個用Python打開的json文件。我想做一些事情,如果一個條件不滿意,我可以跳過當前的元素並繼續下一個。我的代碼如下所示:跳過列表元素 - Python

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 

我的問題與最後一步進來。我是新來的蟒蛇,我不知道如何跳過當前元素

+3

['continue'](http://docs.python.org/2/ tutorial/controlflow.html#break-and-continue-statements-and-else-clause-on-loops)語句? – thefourtheye

+0

您還需要將這兩個文件加載到內存中。由於你是新手代碼,我建議你應該在這裏發佈整個代碼。另外,請看@thefourtheye建議的continue語句。 –

+0

所以沿着token = test_list.skip()的行繼續? – carebear

回答

3

只需使用continue

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