itza itza - 2 months ago 6x
Python Question

Python what is the name of ':.' or what are search terms to bring up its meaning

Following from this question Stackoverflow question the answer provided has ':.' character inside the print statement. i.e


My question is what is the ':.' called? i want to search it and learn what other options there are.


They are separate things.

The .2f is a part of the format specifier which says print only the first two digits after the decimal point.

The : is another part of the format specifier as described here:

"Each field can also specify an optional set of 'format specifiers' which can be used to adjust the format of that field. Format specifiers follow the field name, with a colon (':') character separating the two:"

"My name is {0:8}".format('Fred')

Outputs 'Fred' plus 4 spaces to make 8 characters:

'My name is Fred    '