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

list_one=re.findall(r"^\s{0}[A-Za-z]*\b", txt,re.M)         #匹配一级目录

addr_to = list(set(list_one))
addr_to.sort(key=list_one.index) #从列表中找出某个值第一个匹配项的索引位置,并实现按目录的顺序排序
posted @ 2017-03-27 20:35  讲义大魔王  阅读(8164)  评论(0编辑  收藏  举报