使用numpy.genfromtxt()python 3.4错误跳过指定数量的列

时间:2015-04-18 17:19:21

标签: python python-3.x genfromtxt

import os
import numpy as np
import matplotlib.pyplot as plt

# Open a file
path = "input/"

filelist = list(filter(lambda s: s.endswith(".asc"), os.listdir(path)))
firstImage = np.genfromtxt (" ".join(ln.split()[1:]) for ln in path+next(iter(filelist)))

有什么不对?获取:TypeError:无法将'bytes'对象隐式转换为str

1 个答案:

答案 0 :(得分:1)

查看函数的doc,它似乎能够开箱即用各种疯狂的东西:

http://docs.scipy.org/doc/numpy/reference/generated/numpy.genfromtxt.html

包括但不限于使用usecols参数,您可以跳过使用某些列。

然后就不需要花哨的操作了