fig.add_subplot(333) n=20 Z=np.ones(n) Z[-1]*=2 plt.pie(Z,explode=Z*0.05,colors=['%f' % (i/float(n)) for i in range(n)], labels=('%.2f' % (i / float(n)) for i in range(n))) plt.gca().set_aspect('equal') plt.xticks([]),plt.yticks([]) plt.show() TypeError: object of type 'generator' has no len()
已解决,labels的括号应为[]否则无法改变