1
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

4

1 回答 1

1

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

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

包括但不限于,使用usecols参数将允许您跳过使用某些列。

那么就不需要花哨的操作了

于 2015-04-20T07:15:05.353 回答