[Solved] Python 3.6 Error: ‘dict’ object has no attribute ‘has_key’

Environment:

Python3.6.5

 

Issues:

When I was using Django, there is an error appear:

‘dict’ object has no attribute ‘has_key’

Here is my code:

 

Reason:

There has_key() method has been deleted since python3.

 

Solution:

Modify:

if dict.has_key(key1):

to

if key1 in adict:

as following:

Done!

Read More:

Leave a Reply

Your email address will not be published. Required fields are marked *