print '{0} is {1}:{2}'.format('123',1,3)
str='dick'
score=80
print '%s score is %d'%(str,score)
本文提供了一个使用Python进行字符串格式化的简单例子。通过代码展示了如何利用.format()方法将变量值插入到字符串中,实现字符串的动态构建。
print '{0} is {1}:{2}'.format('123',1,3)
str='dick'
score=80
print '%s score is %d'%(str,score)
4064

被折叠的 条评论
为什么被折叠?