>>> fruit = 'banana' >>> letter = fruit[1]
A basic conversion specifier consists of the items that follow. Note that the order of these items is crucial.
Conversion Type | Meaning |
d, i | Signed integer decimal |
o | Unsigned octal |
u | Unsigned decimal |
x | Unsigned hexadecimal (lowercase) |
X | Unsigned hexadecimal (uppercase) |
e | Floating-point exponential format (lowercase) |
E | Floating-point exponential format (uppercase) |
f, F | Floating-point decimal format |
g | Same as e if exponent is greater than –4 or less than precision; f otherwise |
G | Same as E if exponent is greater than –4 or less than precision; F otherwise |
c | Single character (accepts an integer or a single character string) |
r | String (converts any Python object using repr) |
s | String (converts any Python object using str) |