关于python 字典的一些东西(不定时更新) 1. class 可以作为key class a: pass b = a() c = dict() c[b] = 1 2. list 不可以作为key但是tuple 可以 a = dict() a[(1,2)] = 1 a[[1,2]] = 1 # error , unhashable type: 'list' a[set([1,2])] = 1 #error a[dict()] = 1 # error 3. 检查是否可以作为key hash [1,2].__hash__ # return None (1,2).__hash__