1 2 3 4 5 6 7 8 9 10 11 12 13 14
| print '{0}, {1}, {2}'.format('a', 'b', 'c') print '{}, {}, {}'.format('a', 'b', 'c') print '{2}, {1}, {0}'.format('a', 'b', 'c') print '{2}, {1}, {0}'.format(*'abc') print '{0}{1}{0}'.format('hello-', 'world-')
print '经纬度: ({0}, {1})'.format('37.24N', '-115.81W') print 'A 经纬度: ({latitude}, {longitude})'.format(latitude='37.24N', longitude='-115.81W') args = ('37.24N', '-115.81W') print 'B 经纬度: ({}, {})'.format(*args) kwargs = {'latitude': '37.24N', 'longitude': '-115.81W'} print 'C 经纬度: ({latitude}, {longitude})'.format(**kwargs)
|
Comments