Link Search Menu Expand Document

String Format

ADE adopt Python’s string format for converting variable in a string to a numerical number.

Please use “{ }” and “:” to replace “%”.

Format Description Number Output
{:d} Decimal Integer 200 200
{:x} Hexadecimal Integer, lower case 200 c8
{:X} Hexadecimal Integer, upper case 200 C8
{:>10d} Number of digits is set to 10, aligned to the right 2 2
{:<10d} Number of digits is set to 10, aligned to the left 2 2
{:^10d} Number of digits is set to 1o, aligned to center 2 2
{:0>2d} {:02} Number of digits is set to 2, 0 is inserted to the left if not enough digits 5 05
{:x>2d} Number of digits is set to 2, x is inserted to the left if not enough digits 5 x5
{:x<2d} Number of digits is set to 2, x is serted to the right if not enough digits 5 5x
{:f} Float Point 3.1415926 3.1415926
{:.0f} Integer 3.1415926 3
{:.2f} Two digits behind the decimal point preserved 3.1415926 3.14
{:+.2f} Signed with two digits behind the decimal point preserved 3.1415926 +3.14
{:,} Thousands digit comma 1000000 1,000,000
{:.0%} Percentage 0.33333 33%
{:.2%} Percentage with two digits behind the decimal point preserved 0.33333 33.33%
{:s} Use str() for converting to a string ‘hello’ hello

Please refer to: https://docs.python.org/2/library/stdtypes.html#string-formatting-operations