python加载txt数据 矩阵
python加载txt数据 矩阵
def loadDataKVSet(fileName): dataMat = [] fr = open(fileName,'r', encoding='utf-8') for line in fr.readlines(): curLine = line.strip().split(',') a_float = [] for num in curLine: a_float.append(num) #fltLine = map(float, curLine) # 将每个元素转成float类型 dataMat.append(a_float) return dataMat
##############################33
QQ 3087438119