Python Printf Style Formating
String objects have one special implicit activity: the % administrator (modulo). This is otherwise called the string designing or interjection administrator. Given design % values (where configuration is a string), % transformation determinations in design are supplanted with nothing or more components of values. The impact is like utilizing the sprintf() in the C language.
On the off chance that configuration requires a solitary contention, values might be a solitary non-tuple object. 5 If not, values should be a tuple with the very number of things indicated by the configuration string, or a solitary planning object (for instance, a word reference).
A transformation specifier contains at least two characters and has the accompanying parts, which should happen in a specific order:
- The '%' character denotes the beginning of the specifier.
- Mapping key (discretionary), comprising of a parenthesized grouping of characters (for instance, (somename)).
- Conversion banners (discretionary), which influence the aftereffect of some transformation types.
- Minimum field width (discretionary). Whenever determined as an '*' (reference bullet), the genuine width is perused from the following component of the tuple in values, and the item to change overcomes after the base field width and discretionary accuracy.
- Precision (discretionary), given as a '.' (speck) trailed by accuracy. Whenever determined as '*' (a mark), the genuine accuracy is perused from the following component of the tuple in values, and the worth to change is overcome after the accuracy.
- Length modifier (discretionary).
- Conversion sort.
The change types are:
- 'd'- >Signed whole number decimal.
- 'I'- >Signed whole number decimal.
- 'o'- >Signed octal worth.
- 'u'- >Obsolete type - it is indistinguishable from 'd'.
- 'x'- >Signed hexadecimal (lowercase).
- 'X'- >Signed hexadecimal (capitalized).
- 'e'- >Floating point outstanding organization (lowercase).
- 'E'- >Floating point dramatic configuration (capitalized).
- 'f'- >Floating point decimal arrangement.
- 'F'- >Floating point decimal organization.
- 'g'- >Floating point design. Utilizes lowercase remarkable arrangement on the off chance that example is not exactly - 4 or at the very least accuracy, a decimal configuration in any case.
- 'G'- >Floating point design. Utilizes capitalized outstanding arrangement on the off chance that example is not exactly - 4 or at least accuracy, a decimal configuration in any case.
- 'c'- >Single character (acknowledges whole number or single person string).
- 'r'- >String (changes over any Python object utilizing repr()).
- 's'- >String (changes over any Python object utilizing str()).
- 'a'- >String (changes over any Python object utilizing ASCII()).
- '%'- >No contention is changed over, resulting in a '%' character in the outcome.
- The other structure causes a main octal specifier ('0o') to be embedded before the primary digit.
- The other structure causes a main '0x' or '0X' (contingent upon whether the 'x' or 'X' design was utilized) to be embedded before the principal digit.
- The other structure makes the outcome generally contain a decimal point, regardless of whether no digits follow it.
- The accuracy decides the number of digits after the decimal point and defaults to 6.