Python错误从列表的副本中删除列表项

时间:2016-08-25 08:59:59

标签: python list

Text = ['This is Today', 'Not Tomorrow','Or Day Before','Not Tomorrow','Or Day After']
Copy = Text

for i in range (0, len(Text) - 1):
    print(i, Text[i])
    Line = Text[i]

    for j in range (i+1, len(Text)):
        print(j, Text[j])
        NLine = Text[j]           

        lev = Levenshtein.ratio(Line, NLine)
        if lev > 0.85:
            print('Before Text Size: ', len(Text))
            del Copy[j]
            print('After Text Size: ', len(Text))
Text = Copy

yield:IndexError:列表索引超出范围 即使del操作在Copy。

0 个答案:

没有答案