您的位置:首页 > 编程语言 > Python开发

Python format格式化输出

2016-04-25 13:39 525 查看
http://www.jb51.net/article/63672.htm

推荐参考

>>> '{0},{1}'.format('hello','python')
'hello,python'
>>> '{0} {1}'.format('hello','python')
'hello python'
>>> 'your name:{name}'.format(name='tom')
'your name:tom'
>>> p=['123',45]
>>> '{0[0]}{0[1]}'.format(p)
'12345'
>>> "{:>10}".format('1111')
'      1111'


记住几个常用的用法就行,其余的要有个印象!
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: