c = file('cluster_info.txt')
for i in zip(ys[-10:],result): # has ten elements
for j in c.readlines():
cluster = j.split(',')
if q in cluster:
m = (q[i],cluster[0])
f = pylab.figure() # code for plot starts here
for n, fname in enumerate(m):
image=Image.open(fname).convert("L")
arr=np.asarray(image)
f.add_subplot(2, 1, n) # this line outputs images on top of each other
pylab.imshow(arr,cmap=cm.Greys_r)
pylab.title("%s, Top:Predicted,Bottom:Observed" %i[0])
pylab.show()
else:
continue
這是一個較大代碼的代碼片段,我期望生成10個圖像/圖,但python不生成圖。我認爲我不是在for循環中正確嵌套if和else:。請告訴我這裏有什麼問題。if語句嵌套在for循環中
do-my-work-for-me標籤在哪裏? – Begemoth