1#look like: your_srting % values
2 #when:
3 #your_string = "any king of character %format"
4 #type(value) = tuple
5# A falg can be added between the % and the format
6
7#Exemple:
8
9print("there is %d ducks in the lake" % 34) #>>> there is 34 duck in the lake
10
11# Or
12
13your_string = "%d of the %d ducks are ducklings"
14values = (12, 32)
15print(your_string % values) #>>> 12 of the 34 ducks are ducklings
16
17Formaters are:
18 # Strings
19 %s to display as string (and do str(value) if needed)
20 #Integers
21 %i to display in default int form
22 %d to display as a decimal integer
23 %x to display as an hexadecimal intedger (with lettre in lowercase)
24 %X to display as an hexadecimal intedger (with lettre in uppercase)
25 %o to display as an octal integer
26 %u to display as an unsigned integer
27 %c to display in ascii (process "chr(value)")
28 #Floats
29 %f to display in default float form
30 %e to display in scientific writing (with a lowercase e to expess exponent)
31 %E to display in scientific writing (with an uppercase E to expess exponent)
32 %g to display as an floating exponent