python 使用set对列表去重,并保持列表原来顺序

# 收件人去重,并保持原来的收件人顺序
mailto = ['cc', 'bbbb', 'afa', 'sss', 'bbbb', 'cc', 'shafa']
addr_to = list(set(mailto))
addr_to.sort(key = mailto.index)

你可能感兴趣的:(python 使用set对列表去重,并保持列表原来顺序)