Python·100 questions

How to nicely format strings (f-string)?

Answer
f'Hello, {name}'.
Format: f'{value:.2f}' for float.
Dates: f'{dt:%Y-%m-%d}'.
Width: f'{n:>10}'.
For debugging: f'{var=}' (3.8+).
Was this answer helpful?

More questions in this topic

Related questions from other topics