Python’s Format Mini-Language for Tidy Strings
When you’re doing string interpolation in your Python code, you often need to format the interpolated values to meet some formatting requirements. To do this, Python provides what is known as the format mini-language, which defines the syntax of a format specifier.
Perhaps you’re comfortable working with strings, but you want to take even more control of them. With proficiency in the format mini-language, you’ll be able to use format specifiers to do things like formatting numbers as currency values, using scientific notation, expressing a value as a percentage, and so much more.
In this tutorial, you’ll:
- Learn the format mini-language syntax
- Align and fill textual output in your code
- Convert between data types in your outputs
- Provide