TypeError: 'dict_keys' object does not support indexing

在python2.x中,dict.keys()返回一個列表,在python3.x中,dict.keys()返回一個dict_keys對象,比起列表,這個對象的行爲更像是set,因此不支持索引的。python

解決方案:list(dict.keys())[index]python3.x

相關文章
相關標籤/搜索