AttributeError: 'dict' object has no attribute 'has_key'
程序员文章站
2022-04-13 12:21:16
运行下面的代码: 出错: 这是因为换成了Python3.6.5,Python3.6.5已经删除了has_key()方法,改成了下面的写法: 就可以正常运行了。 ......
运行下面的代码:
if (locals().has_key('data')): del data gc.collect()
出错:
if (locals().has_key('data')): attributeerror: 'dict' object has no attribute 'has_key'
这是因为换成了python3.6.5,python3.6.5已经删除了has_key()方法,改成了下面的写法:
if 'data' in locals(): del data gc.collect()
就可以正常运行了。
推荐阅读
-
AttributeError: 'dict' object has no attribute 'has_key'
-
python错误:AttributeError: 'module' object has no attribute 's
-
python编程排除163邮箱发送邮件报错(AttributeError: ‘tuple‘ object has no attribute ‘encode‘)
-
python编程排除163邮箱发送邮件报错(AttributeError: ‘tuple‘ object has no attribute ‘encode‘)
-
AttributeError: module ‘community‘ has no attribute ‘best_partition‘ 问题解决方法
-
【python】解决AttributeError: module ‘scipy.misc‘ has no attribute ‘toimage‘问题
-
【Tensorflow】Linux下Tensorflow报错:AttributeError: module ‘tensorflow‘ has no attribute ‘xxxx‘
-
AttributeError: 'module' object has no attribute 'main'
-
AttributeError: module 'sklearn' has no attribute 'linear_model'
-
解决Keras报错AttributeError: 'NoneType' object has no attribute 'inbound_nodes'