Raw string literals in Python are string literals that are prefixed with the letter “r” or “R". This prefix signals to the Python interpreter that the string should not be treated in the usual way. All characters in the string will be interpreted literally, rather than evaluated as special characters.
To format a raw string, you'll need to use a formatting specifier. The most common formatting specifier is the %s specifier, which stands for string. This will allow you to format a string using the Python string formatting syntax. For instance, to format a string with two variables a and b, you would use %s %s within the string.
For example:
a = 'foo'
b = 'bar'
my_string = r"The values are %s and %s" % (a,b)
print(my_string)
This would print "The values are foo and bar".
It is also possible to use a formatted raw string. To do this, use the format() function within the raw string. The format() function uses brackets, where the variables are placed inside, which are then replaced with their values. The raw string can then be called using the format() function.
For example:
a = 'foo'
b = 'bar'
my_string = r"The values are {0} and {1}".format(a,b)
print(my_string)
This would print "The values are foo and bar".