python / 未分类 · 2013年11月13日

format

format 格式字符串
符号 {} 是替换变量的占位符。若没有指定格式,则直接将变量值作为字符串插入
In [1]: print 'We are the {0} who say "{1}!"'.format('knights', 'Ni')
We are the knights who say “Ni!”
##salt moudle 常常遇见
qry = ‘CHECK TABLE `{0}`.`{1}`’.format(name, table)
括号内的字符(称为格式字段)被替换的对象。{}括号中的数字是指替换的位置,里面的数字,比如0,1表示替换元组的索引位置。
python 字符串(string) format介绍和代码
http://www.cnpythoner.com/post/291.html#
格式字符串(string formatter)
http://youngsterxyf.github.io/2013/01/26/python-string-format/
http://blog.csdn.net/xiaofeng_yan/article/details/6648493