Numeric and nonnumeric strings can be formatted using format strings, which consist of numeric masks and format masks. The numeric mask code controls justification, precision, scaling, and credit indication. The format mask code controls field length and fill characters.
The entire format string is enclosed in quotation marks. If a format mask is used, it should be enclosed in parentheses within the quotation marks. The entire format string can be used as a literal, or it can be assigned to a variable. A format string literal can immediately follow the string it is to format. A format string variable must be separated by at least one space from the string it is to format. The format string can also be used directly in conjunction with the print statement.
See Also