Mega Code Archive

 
Categories / Python Tutorial / String
 

The syntax for using the format operator is as follows

Format Symbol  Conversion %c              Character (integer [ASCII value] or string of length 1) %r              String conversion via repr() prior to formatting %s              String conversion via str() prior to formatting %d / %i          Signed decimal integer %u              Unsigned decimal integer %o              (Unsigned) octal integer %x/ %X          (Unsigned) hexadecimal integer (lower/UPPERcase letters) %e / %E         Exponential notation (with lowercase 'e'/UPPERcase 'E') %f / %F         Floating point real number (fraction truncates naturally) %g / %G         The shorter of %e and %f/%E% and %F% %%              Percent character ( % ) unescaped