1 __author__ = 'liunnis'
 2 #-*-coding:utf-8 -*-
 3 a=[1,2,3,4,4]
 4 print a
 5 print list(set(a))
 6 b=[str(i) for i in a]
 7 print list(set(b))
 8 #the result is
 9 # [1, 2, 3, 4, 4]
10 # [1, 2, 3, 4]
11 # ['1', '3', '2', '4']
12 c=[[1,2],[3,4],[5,5],[6,6],[7,8],[9,0],10,[11]]
13 print c
14 try:
15     print set(c)
16 except TypeError,e:
17     print'Error:',e
18 #the result is
19 # [[1, 2], [3, 4], [5, 5], [6, 6], [7, 8], [9, 0], 10, [11]]
20 # Error: unhashable type: 'list'

 

相关文章:

  • 2021-11-17
  • 2021-11-24
  • 2021-10-31
  • 2022-12-23
  • 2021-06-25
  • 2021-11-22
  • 2022-01-12
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-11-14
  • 2022-12-23
  • 2021-10-23
  • 2021-10-21
  • 2021-11-20
相关资源
相似解决方案