码迷,mamicode.com
首页 > 编程语言 > 详细

Python format格式化输出

时间:2016-04-25 15:03:07      阅读:206      评论:0      收藏:0      [点我收藏+]

标签:

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‘

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

Python format格式化输出

标签:

原文地址:http://www.cnblogs.com/dream-for/p/5430643.html

踩
(0)
赞
(0)
   
举报
评论 一句话评论(0)
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!