小编A77*_*7ak的帖子

在Python中嵌套

我有一个列表,我想迭代它,然后迭代嵌入for在第一个我读过的下一个位置的同一个列表中的第一个.

在像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]
Run Code Online (Sandbox Code Playgroud)

我怎么能在Python上做到这一点?我试试这个:

for a in array:
     del array[0]
     for a2 in array:
         //do something with the array comparing a and a2
Run Code Online (Sandbox Code Playgroud)

但只适用于第一次迭代..任何帮助?

python nested python-2.7

1
推荐指数
1
解决办法
92
查看次数

标签 统计

nested ×1

python ×1

python-2.7 ×1