PyDocs

Nav

Python Runtime Services

format

builtins

function
  • format(value, format_spec='', /)
Return type(value).__format__(value, format_spec)

Many built-in types implement format_spec according to the
Format Specification Mini-language. See help('FORMATTING').

If type(value) does not supply a method named __format__
and format_spec is empty, then str(value) is returned.
See also help('SPECIALMETHODS').
Changed in 3.4
  • 3.4: object().__format__(format_spec) raises TypeError if format_spec is not an empty string.
0 Examples
No examples for builtins/format.
See Also
No see-alsos for builtins/format
0 Notes
No notes for format