MicroPython String Formatting
The normal Python has advanced string formatting functions using "%" and .format methods documented at the PyFormat website.
Although most of these functions work, there are some exceptions when using date formats.
The following % formats do not work under MicroPython:
- %Y - year
- %m - month
- %d - day of month
- %H - hour of day
- %M - minute
Padding Example
The following example prints a floating point number with two decimals of precision in a field of six characters with leading zeros.
1 |
|
returns:
1 |
|