python字符串格式化

>>> str = "so %s a day!"
>>> str % 'beautiful'
'so beautiful a day!'

>>> '{0} is {1}'.format('a','b')
'a is b'

>>> template = "{0}, {1} and {2}"
>>> template.format('a', 'b', 'c')
'a, b and c'

你可能感兴趣的:(python字符串格式化)