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‘
记住几个常用的用法就行,其余的要有个印象!
时间: 2024-10-08 07:20:16