可变量list不能作为dict或set的key,注意是key而不是值!!
s1 = (1,2,3) s2 = (1,[2,3]) d1 = {s1:'abc'} d2 = {s2,'efg'} Traceback (most recent call last): File "<stdin>", line 1, in <module> TypeError: unhashable type: 'list' L1 = set(s1) L2 = set(s2) Traceback (most recent call last): File "<stdin>", line 1, in <module> TypeError: unhashable type: 'list'
Sign in to make a reply
swallowtail_文斌
可变量list不能作为dict或set的key,注意是key而不是值!!