Skip to content

Instantly share code, notes, and snippets.

@sincerefly
Created April 29, 2015 11:44
Show Gist options
  • Save sincerefly/9d42ab0814344f03e4ba to your computer and use it in GitHub Desktop.
Save sincerefly/9d42ab0814344f03e4ba to your computer and use it in GitHub Desktop.
使用set去重,维持原列表顺序
def unique(integers):
int_list = list(set(integers))
int_list.sort(key = integers.index)
return int_list
print unique([4, 1, 2, 4, 3])
# result [4, 1, 2, 3]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment