itza itza - 1 year ago 84
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.

Answer Source

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    '
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download