'dict' object has no attribute 'has_key'

后端 未结 6 982
太阳男子
太阳男子 2021-01-30 03:46

While traversing a graph in Python, a I\'m receiving this error:

\'dict\' object has no attribute \'has_key\'

Here is my code:

6条回答
  •  死守一世寂寞
    2021-01-30 04:21

    has_key was removed in Python 3. From the documentation:

    • Removed dict.has_key() – use the in operator instead.

    Here's an example:

    if start not in graph:
        return None
    

提交回复
热议问题