Код: Выделить всё
!s
значения перед его форматированием.
Код: Выделить всё
>>> import math
>>> print 'The value of PI is approximately {}.'.format(math.pi)
The value of PI is approximately 3.14159265359.
>>> print 'The value of PI is approximately {!r}.'.format(math.pi)
The value of PI is approximately 3.141592653589793.
Интересно, что преобразованное значение является результатом функции repr(), а не str().
Код: Выделить всё
>>> str(math.pi)
'3.14159265359'
>>> repr(math.pi)
'3.141592653589793'
Подробнее здесь: https://stackoverflow.com/questions/384 ... r-and-repr