我有一個列表,我想迭代在它上面,然後在嵌套for
中迭代第一個從我讀取的第一個下一個位置開始。在Python中嵌套
在Java等語言是:
int[10] array;
for (int i=0; i < array.length(); i++)
for (int j=i+1; j < array.length(); j ++)
//do something with the array comparing a[i] and a[j]
我怎麼能這樣做Python的? 我試試這個:
for a in array:
del array[0]
for a2 in array:
//do something with the array comparing a and a2
但是,只有在第一次迭代工程..任何幫助嗎?
你爲什麼'del array [0]'? Java代碼不會從數組中刪除任何內容 –