Created
April 29, 2015 11:44
-
-
Save sincerefly/9d42ab0814344f03e4ba to your computer and use it in GitHub Desktop.
使用set去重,维持原列表顺序
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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