Hashing arrays in Python

前端 未结 3 1721
难免孤独
难免孤独 2020-12-05 09:08

Is it possible to hash lists?

For example, I know that hashes of tuples are possible:

>>> hash((1,2,3,4,5,6))
-319527650
         


        
3条回答
  •  醉酒成梦
    2020-12-05 10:12

    If you really need to use a list as a dictionary key, try converting it to a string first.
    my_list = str(my_list)

提交回复
热议问题