10.python中如何从一个序列中去除重复项

很简单,用python的set()内建函数就可以实现:
#-*-coding:UTF-8-*-
#在序列中寻找不同的元素
a_list=[1,1,2,2,3,4,5,6,7]
print set(a_list)                #set函数将返回一个没有重复项的集合

a_string='AABBCC DDEEFF'
print set(a_string)              #将一个字符串转换为一个没有重复项的字符列表

words=['send','mord','money']
print ''.join(words)             #将多个字符串连接为一个字符串

print set(''.join(words))

原文地址:https://www.cnblogs.com/chenjianhong/p/4145134.html