0

What is the difference between this "Old" type of formatting and the "New" type of formatting?

New: '%s %s' % ('one', 'two')

Old: '{} {}'.format('one', 'two')

Can someone explain this to me? Every example I've tried has given me the same result regardless of either formatting option. Is this just for personal preference? If so that seems kind of wasteful?

EDIT: also what is this? f'{one} {two}' as mentioned in the comments....

11
  • 2
    and what about the newnew f'{one} {two}' ? Commented Oct 5, 2017 at 18:57
  • 1
    the % one is now deprecated. format is way more powerful. Commented Oct 5, 2017 at 18:58
  • 1
    python 3.6 only IIRC Commented Oct 5, 2017 at 18:58
  • 2
    the f prefix is new in the language. You need python 3.6 Commented Oct 5, 2017 at 18:59
  • 1
    python comes back to its roots ... -> C Commented Oct 5, 2017 at 19:02

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.