以下示例:
string1 = "calvin klein design dress calvin klein"
如何删除后两个重复项"calvin"和"klein"?
"calvin"
"klein"
结果应该看起来像
string2 = "calvin klein design dress"
仅应删除第二个重复项,并且不应更改单词的顺序!
def unique_list(l): ulist = [] [ulist.append(x) for x in l if x not in ulist] return ulist a="calvin klein design dress calvin klein" a=' '.join(unique_list(a.split()))