is formally described as follows (brackets denote optional components and are not coded literally)[[fill]align][sign][#][ ][width][,]precision][typecodein thisfill can be any fill character other than or }align may be =or ^for left alignmentright alignmentpadding after sign characteror centered alignmentrespectivelysign may be +-or spaceand the (commaoption requests comma for thousands separator as of python and width and precision are much as in the expressionand the formatspec may also contain nested {format strings with field names onlyto take values from the arguments list dynamically (much like the in formatting expressionsthe method' typecode options almost completely overlap with those used in expressions and listed previously in table - but the format method also allows type code used to display integers in binary format (it' equivalent to using the bin built-in call)allows type code to display percentagesand uses only for base- integers ( or are not used herenote that unlike the expression' %sthe type code here requires string object argumentomit the type code to accept any type generically see python' library manual for more on substitution syntax that we'll omit here in addition to the string' format methoda single object may also be formatted with the format(objectformatspecbuilt-in function (which the method uses internally)and may be customized in user-defined classes with the __format__ operator-overloading method (see part viadvanced formatting method examples as you can tellthe syntax can be complex in formatting methods because your best ally in such cases is often the interactive prompt herelet' turn to some examples in the following{ : means the first positional argument in field characters wide{ :< means the second positional argument left-justified in -character-wide fieldand { platform:> means the platform attribute of the first argument rightjustified in -character-wide field (note again the use of dict(to make dictionary from keyword argumentscovered in and )'{ : { : }format('spam' 'spam in python '{ :> { :< }format('spam' spam '{ platform:> { [kind]:< }format(sysdict(kind='laptop')win laptop in all casesyou can omit the argument number as of python and if you're selecting them from left to right with relative autonumbering--though this makes your string formatting method calls