String formatting. : Format « String « Python Tutorial

integerValue = 4237
print "Integer ", integerValue
print "Decimal integer %d" % integerValue 
print "Hexadecimal integer %x\n" % integerValue

floatValue = 123456.789
print "Float", floatValue
print "Default float %f" % floatValue
print "Default exponential %e\n" % floatValue

print "Right justify integer (%8d)" % integerValue
print "Left justify integer  (%-8d)\n" % integerValue

stringValue = "String formatting"
print "Force eight digits in integer %.8d" % integerValue
print "Five digits after decimal in float %.5f" % floatValue
print "Fifteen and five characters allowed in string:"
print "(%.15s) (%.5s)" % ( stringValue, stringValue )

5.10.1.String formatting is done with the string formatting operator, the percent (%) sign.
5.10.2.Formatted String
5.10.3.String format
5.10.4.A basic conversion specifier
5.10.5.use the string format operator ( % ), or put all of the substrings in a list, and using one join() call to put them all together
5.10.6.The syntax for using the format operator is as follows: format_string % (arguments_to_convert)
5.10.7.Format Operator Auxiliary Directives
5.10.8.String Formatting Conversion Types
5.10.9.print paired with the string format operator ( % )
5.10.10.Width and Precision
5.10.11.Signs, Alignment, and Zero-Padding
5.10.12.A minus sign (-) left-aligns the value:
5.10.13.A blank (" ") means that a blank should be put in front of positive numbers
5.10.14.a plus (+) means that a sign should precede both positive and negative numbers
5.10.15.String formatting.
5.10.16.String-formatting codes
5.10.18.The %e, %f, and %g formats display floating-point numbers in different ways, as the following interaction demonstrates:
5.10.19.Dictionary-Based String Formatting