所以我继承了一段相当糟糕的代码。缩进就像我发现的那样。为什么 else 不抛出错误?据我所知,代码永远不会到达它。
for l in range(1,9):
indexes = pickle.load(open('%s_%d.pkl'%(fc,l)))
clusters_sum = sum([indexes[i]['count'] for i in indexes])
print >> out, 'Lane %d: %d clusters PF.\n%8s %9s %5s' % (l,clusters_sum,'Index','Count','%')
for i in sorted(indexes, key=lambda x: indexes[x]['name']):
pct = indexes[i]['count'] and indexes[i]['count']/clusters_sum*100 or 0
if pct < 0.06: continue
print >> out, '%8s %9d %5.1f' % (indexes[i]['name'], indexes[i]['count'], pct)
else: print >> out