当先锋百科网

首页 1 2 3 4 5 6 7
from sklearn.feature_extraction import DictVectorizer
import csv
from sklearn import preprocessing
from sklearn import tree
from sklearn.externals.six import StringIO

#打开CSV文件'rb'是以二进制格式打开一个文件用于只读。文件指针将会放在文件的开头
data = open(r'F:\2.深度神经网络算法之基础精讲\机器学习深度神经网络学习基础一  29课\代码与素材(1)\01DTree\AllElectronics.csv','rb')
reader = csv.reader(data)
header = reader.next()

print(header)
featureList = []
lableList = []

 

python 3中reader已经没有next()属性了,而使用:

header = next(reader)

 

from sklearn.feature_extraction import DictVectorizer
import csv
from sklearn import preprocessing
from sklearn import tree
from sklearn.externals.six import StringIO

#打开CSV文件'rb'是以二进制格式打开一个文件用于只读。文件指针将会放在文件的开头
data = open(r'F:\2.深度神经网络算法之基础精讲\机器学习深度神经网络学习基础一  29课\代码与素材(1)\01DTree\AllElectronics.csv','rt')
reader = csv.reader(data)
header = next(reader)

print(header)
featureList = []
lableList = []

 

 

 

转载于:https://www.cnblogs.com/yichenxing/p/11363084.html