format
Uses this text as a format string and returns the text obtained by substituting the specified arguments.
Supports many of the format specifiers found in other programming languages, including:
%sfortext%dforintegers andbig_integers in decimal (base 10) representation%oforintegers andbig_integers in octal (base 8) representation%xforintegers andbig_integers in hexadecimal (base 16) representation%ffordecimal(supports precision, e.g.%.2ffor two decimal places)%bforbooleans (output in lower-case, i.e.trueandfalse)%Bforbooleans (output in upper-case, i.e.TRUEandFALSE)
Examples:
'My integer is %d.'.format(123)returns'My integer is 123.'.'See you...%10s.'.format('later')returns'See you... later.'.'Earnings: daily=%f, weekly=%f, monthly=%f.'.format(312.45, 534.78, 2199.67)returns'Earnings: daily=312.450000, weekly=534.780000, monthly=2199.670000.'.''%d %o %x'.format(14, 14, 14)'returns'14 16 e'.
If any format specifier is incompatible with the type of its corresponding argument, or if there are more specifiers requiring substitution than there are arguments, all format specifiers are left unsubstituted in the output text.
All format specifiers are also left unsubstituted in the output text when any argument is null, except when it matches the specifier is %s, in which case the text 'null' is substituted (assuming the other arguments and specifiers are correctly matched).
If there are more arguments than format specifiers, the extra arguments are ignored, but matched arguments are still substituted (assuming they match correctly).
Return
formatted text
Since
0.6.0
Parameters
Arguments referenced by the format specifiers in this format string. The number of arguments is variable and may be zero.