读书人

unhashable type:#039;list#039;什么意思,该怎

发布时间: 2012-05-20 16:03:12 作者: rapoo

unhashable type:'list'什么意思
unhashable type:'list'什么意思
Python中

[解决办法]
Lists cannot be dictionary keys more on this later:
>>> mydict = {[1,2] : "wont_work"}
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: unhashable type: 'list'

list的内容是可变的,不可hash,因此不能作为dict的keys.

读书人网 >perl python

热点推荐