1030
>>> b
[1, 3, [1, 2], [1, 2]]
>>> list(b)
[1, 3, [1, 2], [1, 2]]
>>> set(b)
Traceback (most recent call last):
File "<pyshell#38>", line 1, in <module>
set(b)
TypeError: unhashable type: 'list'
原因:set 用hash計算的奋构,因此元素不可變,但是列表是可變的
1030
>>> b
[1, 3, [1, 2], [1, 2]]
>>> list(b)
[1, 3, [1, 2], [1, 2]]
>>> set(b)
Traceback (most recent call last):
File "<pyshell#38>", line 1, in <module>
set(b)
TypeError: unhashable type: 'list'
原因:set 用hash計算的奋构,因此元素不可變,但是列表是可變的