.format vs. %

Miki Tebeka miki.tebeka at gmail.com
Sun Jan 1 16:11:44 EST 2012


> >>> s = "{0} {1} {2} {3}"
> >>> s.format(1, 2, 3, 4)
> '1 2 3 4'
Or even
    In [4]: fmt = '{0} {1} {2} {3}'.format
    In [5]: print(fmt(1, 2, 3, 4))
    1 2 3 4




More information about the Python-list mailing list