2012-12-05 23 views

回答

4

我花了超過幾分鐘的時間來得到正確安裝原緩衝編譯器,這樣就可能是足夠的理由無視這個:)

雖然它不是在文檔中,你可以實際上對待一個重複的領域很像一個正常的名單。除了它的私有方法,它支持addextendremovesort,並且remove是你正在尋找在第一種情況:

foo.bars.remove(bar) 

這裏是打印foo上述前行,當輸出(定義通過上面的代碼)後:

Original foo: 
bars { 
    i: 15 
} 
bars { 
    i: 32 
} 

foo without bar: 
bars { 
    i: 32 
} 

作爲除去nth元素,你可以使用del和你想要的索引位置刪除:

# Delete the second element 
del foo.bars[1] 

和輸出:

Original foo: 
bars { 
    i: 15 
} 
bars { 
    i: 32 
} 

Removing index position 1: 
bars { 
    i: 15 
} 

希望幫助!

+0

我不確定這是否是版本問題,但刪除的「.remove」方法不適用於我。第二個版本確實有效。 – Catskul

相關問題