string.format()

string.format()

string.format() method

.format(*args, **kwargs)
print("The sum of 1 + 2 is {0}".format(3))
# 'The sum of 1 + 2 is 3'
  • Perform a string formatting operation.
  • The string on which this method is called can contain literal text or replacement fields delimited by braces {}.
  • Returns a copy of the string where each replacement field is replaced with the string value of the corresponding argument.

Related concepts

string.format()

string.format() — Structure map

Clickable & Draggable!

string.format() — Related pages: