2
我想使用numpy.where中的索引值來打印該索引的字符串內容。我試圖通過遍歷數組從0到數組的長度來做到這一點。但長度總是1 ..?爲什麼我的數組長度爲1時,用numpy.where構建它?
import numpy as np
v,w,x, y, z = np.loadtxt('test.txt', dtype=str, delimiter='|',
skiprows=2,usecols=(0,1,2,3,4), unpack=True)
a,b,c, d, e = np.loadtxt('test2.txt', dtype=str, delimiter='|',
skiprows=2,usecols=(0,1,2,3,4), unpack=True)
checkValue = np.in1d(a, v)
missingValue=(np.where(checkValue==False))
print len(missingValue)
for i in range (len(MissingValue)):
print a[i]
此打印僅一個的值,但是在陣列實際上具有10
大,這使得更多的意義,現在,我的代碼工作。非常感謝。 – user2177088 2013-04-21 03:33:06