Following the part of a format code, you can use one of these two forms
to force the value to be converted by a standard function:
name
!s | str() |
!r | repr() |
Here's an example:
>>> "{}".format('Don\'t')
"Don't"
>>> "{!r}".format('Don\'t')
'"Don\'t"'