Python format格式化输出

http://www.jb51.net/article/63672.htm

推荐参考

 1 >>> '{0},{1}'.format('hello','python')
 2 'hello,python'
 3 >>> '{0} {1}'.format('hello','python')
 4 'hello python'
 5 >>> 'your name:{name}'.format(name='tom')
 6 'your name:tom'
 7 >>> p=['123',45]
 8 >>> '{0[0]}{0[1]}'.format(p)
 9 '12345'
10 >>> "{:>10}".format('1111')
11 '      1111'

记住几个常用的用法就行,其余的要有个印象!

posted @ 2016-04-25 13:39  dreamfor  阅读(327)  评论(0编辑  收藏  举报