【发布时间】:2023-01-19 14:55:17
【问题描述】:
我有一个函数返回一个数组,第二个函数应该使用这个返回的数组,但程序返回说数组未定义。我该如何解决这个问题?
def popt_reader(filename):
with codecs.open(popt, 'r', encoding='utf-8') as data_file:
rows, cols = [int(c) for c in data_file.readline().split() if c.isnumeric()]
array = np.fromstring(data_file.read(), sep=' ').reshape(rows, cols)
return array
def cleaner():
out = []
en_point = 0
for i in range(1,len(array)):
if np.all((array[i,1::] == 0)):
pass
else:
out.append(array[i,:])
en_point += 1
print(en_point)
cleaner(array)
【问题讨论】:
标签: python-3.x