(记录)初学python篇:五
>>> a=(1,2,3)>>> type(a)
<class 'tuple'>
>>> b=(1,)
>>> type(b)
<class 'tuple'>
>>> c={"w":1,"g":2}
>>> d=set()
>>> type(c)
<class 'dict'>
>>> type(d)
<class 'set'>
>>> c["a"]=a
>>> a
(1, 2, 3)
>>> c
{'w': 1, 'g': 2, 'a': (1, 2, 3), 'b': (1, 2, 3)}
>>> c["b"]=b
{'w': 1, 'g': 2, 'a': (1, 2, 3), 'b': (1, )}
>>> d.add(a)
>>> d
{1, 2, 3, (1, 2, 3)}
>>> d.add(b)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: unhashable type: 'list'
页:
[1]