Skip to content

Instantly share code, notes, and snippets.

@unionx
Created October 19, 2012 02:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save unionx/3915983 to your computer and use it in GitHub Desktop.
Save unionx/3915983 to your computer and use it in GitHub Desktop.
我终于知道tuple这个数据类型有什么用了
#!/usr/bin/env python
list_in_list = [[1,2,3], [2,2,2], [1,2,3]]
try:
dist_list = list(set(list_in_list))
except TypeError:
print("list in list")
tuple_in_list = [(1,2,3), (2,2,2), (1,2,3)]
dist_list = list(set(tuple_in_list))
# dist_list is [(2,2,2), (1,2,3)]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment