Python入门(基础)踩过的坑
来源:互联网 发布:三国志9怎么开优化 编辑:程序博客网 时间:2024/05/21 19:47
AttributeError: ‘dict’ object has no attribute ‘iteritems’
从python3.5开始字典不在有这个属性,iteritems变为items。
对于函数operator.itemgetter()的理解:
例一:
对dist=[(a,dist1,d1),(b,dist2,d2),(c,dist,d3)]里的三个元素做排序
dist.sort(key = operator.itemgetter(1))#根据每个元素里的第二个数值大小来排序。
reverse参数就不用多说了,是一个bool变量,表示升序还是降序排列,默认为false(升序排列),定义为True时将按降序排列。
例二:
a =[1,2,3]
b=operator.itemgetter(1)
b(a)=2
环境:scikit-learn 0.18 , python3.6X
在用别人程序的时候,报警告:
#from sklearn.cross_validation import train_test_split#from sklearn.grid_search import GridSearchCV
klearn\cross_validation.py”, line 41
“This module will be removed in 0.20.”, DeprecationWarning)
DeprecationWarning: This module was deprecated in version 0.18 in favor of the model_selection module into which all the refactored classes and functions are moved. Also note that the interface of the new CV iterators are different from that of this module. This module will be removed in 0.20.
解决办法:该模块在0.18版本中被弃用,支持所有重构的类和函数都被移动到的model_selection模块
from sklearn.model_selection import train_test_splitfrom sklearn.model_selection import GridSearchCV
- Python入门(基础)踩过的坑
- python入门opencv踩过的坑
- Hadoop开发入门踩过的坑(持续更新)
- python踩过的一些坑
- Python基础入门(一)- Python 的特点
- Python基础入门(五)- python的数据类型
- Python基础入门(1)
- Python入门(二,基础)
- Python入门基础(一)
- Python入门基础(二)
- Python入门基础(三)
- Python入门基础(二)
- Python入门基础(三)
- Python基础入门(四)
- Python入门(基础语法)
- 【python入门笔记】(二)python基础
- Python基础:Python入门
- Python基础入门(十七)-函数里的参数
- html中控制video标签全屏
- 中间交付个人总结
- 编程思想 | 自顶向下,逐步求精
- 使用flex实现页面布局
- linux vim编辑器之环境设置
- Python入门(基础)踩过的坑
- C++的inline函数
- poj2970The lazy programmer 优先队列+贪心
- Libevent源码分析 (1) hello-world
- react入坑之父子组件之间的传值
- 【学习笔记】设计模式-观察者模式
- zbnet3
- Mycat 的分片(水平分片)实例
- PEP——3113