如何简化下面的语法?
three='Three'
result='One-Two-%s, One-Two-%s, One-Two-%s'%(three,three,three))
稍后编辑:
另一个惊喜:得到 KeyError: 'border' :
color='#262626'
style="QProgressBar{background-color: {ph:s}}".format(ph=color)
请您参考如下方法:
>>> three = 'Three'
>>> result = 'One-Two-{ph:s}, One-Two-{ph:s}, One-Two-{ph:s}'.format(ph=three)
>>> print result
One-Two-Three, One-Two-Three, One-Two-Three
编辑:
>>> style="QProgressBar{{background-color: {ph:s}}}".format(ph=color)
>>> print style
QProgressBar{background-color: #262626}
