Before python 3.6 there were two ways to format python strings.
str.format() and the
% style formatting. Before we explore f-strings let's see what we are used to to.
str.format() is an old style of formatting strings. It provides various ways of formatting string including positional parameters, named parameters and ordered parameters. Here are some examples.
%-style formatting of string is another popular way of formatting strings in python Let's see by an example
%-style formatting is an ordered formatting i.e. parameters are replaced as they appear in order.
Both the methods
%-style have readability and performance issues
You can learn more about their performance here
f-strings for formatted string literals are string constants that can have un-evaluated python expressions that will be evaluated at run time.
f-strings starts with
f. Let's see an example.
There is much more you can write in curly braces, any valid python expression, constants, function call with valid arguments.