AttributeError: 'dict' object has no attribute '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'的更多相关文章
- AttributeError: 'dict' object has no attribute 'iteritems'
在python3.6中运行 sortedClassCount = sorted(classCount.iteritems(), key=operator.itemgetter(1), reverse= ...
- AttributeError: 'dict' object has no attribute 'encode'
首先这是一个很简单的 运行时错误: 错误分析: AttributeError:属性错误,造成这种错误的原因可能有: 你尝试访问一个不存在的属性或方法.检查一下拼写!你可以使用内建函数 dir 来列出存 ...
- flask 表单填充数据报错!AttributeError: 'dict' object has no attribute 'getlist'
报错信息: AttributeError: 'dict' object has no attribute 'getlist' 解决: 虽然是小毛病,不得不说还是自己太粗心大意了.
- facenet pyhton3.5 训练 train_softmax.py 时报错AttributeError: 'dict' object has no attribute 'iteritems'
报错原因:在进行facenet进行train_softmax.py训练时,在一轮训练结束进行验证时,报错AttributeError: 'dict' object has no attribute ' ...
- AttributeError: 'dict' object has no attribute 'status_code'
前端AJAX请求数据,提示错误:“AttributeError: 'dict' object has no attribute 'status_code'”. 原因:是提示返回对象dict没有“sta ...
- 报错 'dict' object has no attribute 'has_key'
has_key方法在python2中是可以使用的,在python3中删除了. 比如: if dict.has_key(word): 改为: if word in dict:
- 机器学习实战:KNN代码报错“AttributeError: 'dict' object has no attribute 'iteritems'”
报错代码: sortedClassCount = sorted(classCount.iteritems(), key=operator.itemgetter(1), reverse=True) 解决 ...
- 'dict' object has no attribute 'a'
a = {} #a.a = 'a' #AttributeError: 'dict' object has no attribute 'a' #a['a'] #KeyError: 'a' a['a'] ...
- Python脚本报错AttributeError: ‘module’ object has no attribute’xxx’解决方法
最近在编写Python脚本过程中遇到一个问题比较奇怪:Python脚本完全正常没问题,但执行总报错"AttributeError: 'module' object has no attrib ...
随机推荐
- day21 模块 异常处理
常用模块:http://www.cnblogs.com/Eva-J/articles/7228075.html 今日概要: #time # —— 时间:时间戳 字符串 结构化时间 #collectio ...
- context-param和init-param的区别
http://www.cnblogs.com/hzj-/articles/1689836.html
- dp经典问题-最大连续子序列和 hdu1003
题目描述: 这道题我先后做过三遍,结果每一遍都没有做出来.今天再仔仔细细的研究了一下,才发现用动态规划更好理解. 关于求最大连续子序列和的博文转载如下:https://www.cnblogs.com/ ...
- JAVA基础中的注意点(一)
1.标识符 标识符:标识某些事物用于区分的符号. (即区分某些事物的符号) 四条硬性规定: a.不能是 关键字.true.false.null. b.可以包含 字母.数字(0-9).下划线(_)或美 ...
- 002.MongoDB社区版安装
一 前期准备 1.1 相关软件包介绍 包裹名字 描述 mongodb-org 一个将自动安装以下四个组件包的组合包. mongodb-org-server 包含mongod守护程序,关联的init脚本 ...
- 深入理解原型链(Prototype chain) __proto__
原型链(Prototype chain) 原型对象也是普通的对象,并且也有可能有自己的原型,如果一个原型对象的原型不为null的话,我们就称之为原型链(prototype chain). A prot ...
- 2019-1-11 SQL语句汇总——聚合函数、分组、子查询及组合查询
- 在UnrealEngine中用Custom节点实现马赛克效果
参考这位大神的Shaderhttp://blog.csdn.net/noahzuo/article/details/51316015 //input BaseUV 屏幕UV //intput Tili ...
- mysql case when then else end 的用法
case when then end 改语句的执行过程是:将case后面表达式的值与各when子句中的值进行比较,如果两者相等,则返回then后的表达式的值,然后跳出case语 句,否则返回else子 ...
- 子串 [NOIP2015]
Description 有两个仅包含小写英文字母的字符串 A 和 B.现在要从字符串 A 中取出 k 个互不重叠的非空子串,然后把这 k 个子串按照其在字符串 A 中出现的顺序依次连接起来得到一 个新 ...