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