Python:在Pylab标题中使用变量

时间:2011-05-27 02:56:50

标签: python matplotlib

我有变量N和W随每次运行而变化。是否可以执行以下操作?:

pylab.title('Minimal Energy Configuration of' N 'Charges on Disc' 'W = 'W)

1 个答案:

答案 0 :(得分:20)

我认为你在谈论字符串插值如下:

pylab.title('Minimal Energy Configuration of %s Charges on Disc W = %s'%(N, W))