|
|
|
|
|
by wylee
3943 days ago
|
|
Your example isn't very compelling, but for longer strings with more complex formatting, I'd say .format() is pretty compelling. I find that in general '{x} blah blah blah {y}'.format(x=x, y=y)
is more readable than '%s blah blah blah %s' % (x, y)
even if the former is a bit longer.On top of that, there's a whole bunch of stuff you can do with .format() that just isn't possible with %. |
|