AttributeError: ‘dict’ object has no attribute ‘has_key’

How did “people you might know” find you on social software>>>

Run the following code:

if (locals().has_key('data')):
        del data
        gc.collect()

Error:

if (locals().has_key('data')):
AttributeError: 'dict' object has no attribute 'has_key'

This is because Python 3.6.5 has been deleted_ The key () method is changed to the following writing method:

if 'data' in locals():
        del data
        gc.collect()

It’s going to work

Similar Posts: