在python3下如上这么写会报错:
TypeError Traceback (most recent call last)
in ()
9 # print(d[0].split(’ ‘))
10 d = map(float, filter(notEmpty, d[0].split(’ ')))
—> 11 data[i] = d
TypeError: float() argument must be a string or a number, not ‘map’
原因
python3下的map()函数返回类型为iterators,python2是list,所以可将上述语句修改为
d = list(map(float, filter(notEmpty, d[0].split(’ '))))
就可以成功运行了