我有Python wavelet包的输出:
[[[[[[255 255 255 255]
[255 255 255 255]
[255 255 255 255]
...,
[255 255 255 255]
[255 255 255 255]
[255 255 255 255]]
[[255 255 255 255]
[255 255 255 255]
[255 255 255 255]
...,
[255 255 255 255]
[255 255 255 255]
[255 255 255 255]]
[[255 255 255 255]
[255 255 255 255]
[255 255 255 255]
...,
[255 255 255 255]
[255 255 255 255]
[255 255 255 255]]
...,
[[255 255 255 255]
[255 255 255 255]
[255 255 255 255]
...,
[255 255 255 255]
[255 255 255 255]
[255 255 255 255]]
[[255 255 255 255]
[255 255 255 255]
[255 255 255 255]
...,
[255 255 255 255]
[255 255 255 255]
[255 255 255 255]]
[[255 255 255 255]
[255 255 255 255]
[255 255 255 255]
...,
[255 255 255 255]
[255 255 255 255]
[255 255 255 255]]]]]]
我需要将它打印到终端和一行中的.csv
文件,标签分隔,不带括号。
def waveletdbbiorone(self): #function for Wavelets computation
for filename in glob.iglob ('*.tif'):
imgwbior = mahotas.imread (filename) #read the image
arraywbior = numpy.array([imgwbior])#make an array for pywt module
coefwbior = pywt.wavedec(arraywbior,'db1')#compute wavelet coefficients
arr = numpy.array([coefwbior])
np.set_printoptions(precision=3)
print arr
答案 0 :(得分:0)
如果你真的只想要一行使用迭代器flat
:
Python 3
>>> for elem in arr.flat:
print('{}\t'.format(elem), end='')
255.0 255.0 255.0 255.0 255.0 .........
Python 2
>>> for elem in arr.flat:
print '{}\t'.format(elem),
255.0 255.0 255.0 255.0 255.0 .........