Skip to content

Instantly share code, notes, and snippets.

@davidbj
Created February 25, 2016 09:28
Show Gist options
  • Select an option

  • Save davidbj/af54dbe3a16c18559ee3 to your computer and use it in GitHub Desktop.

Select an option

Save davidbj/af54dbe3a16c18559ee3 to your computer and use it in GitHub Desktop.
List Deduplication
def list_deduplication():
"""List Deduplication.
"""
ld = [1, 3, 2, 4, 3, 4, 2, 5, 5, 7]
nld = []
[nld.append(str(i)) for i in ld if str(i) not in nld]
return ','.join(nld)
list_deduplication()
@davidbj
Copy link
Author

davidbj commented Feb 27, 2016

优化:
tmp=set()
[nld.append(str(i)), tmp.append(str(i)) for i in ld if str(i) not in tmp]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment